• Resolved streetlc

    (@streetlc)


    Hello,

    To improve my Woocommerce store under wordpress, I had the archive-product.php theme file modified, like this:

    <?php if ( have_posts() ) : ?>
    <br><br>
    <h2 class=”titlecategoryspecial”>MY TITLE</h2>
    <p class=”paracategoryspecial”>MY DESCRIPTION</p>

    <?php echo do_shortcode(“[product_category category=’name-of-my-category’ per_page=’24’ columns=’3′ orderby=’menu_order’]”); ?>

    This allows me a better display on my shop page, divided into several personalized blocks according to my different categories, all on the same page.

    By doing this, I also pass the woocommerce display, and I can no longer point to a particular category with a widget or the classic menu links. They all take me back to the store page.

    So I’m looking to integrate an html link anchor on each H2 title by product category and in a particular location on the page (bottom, middle, top).

    I added the classic id = “”.

    <?php if ( have_posts() ) : ?>
    <br><br>
    <h2 id=”nameofthelink” class=”titlecategoryspecial”>MY TITLE</h2>
    <p class=”paracategoryspecial”>MY DESCRIPTION</p>

    <?php echo do_shortcode(“[product_category category=’name-of-my-category’ per_page=’24’ columns=’3′ orderby=’menu_order’]”); ?>

    Unfortunately, it didn’t work: https://www.mywebsite.com/shop/#nameofthelink
    When I point my html link #nameofthelink I stupidly land on my shop page.

    Someone would have any idea ?

    Thank you in advance,

    Best regards,

    • This topic was modified 6 years, 1 month ago by streetlc.
Viewing 9 replies - 1 through 9 (of 9 total)
  • Hey @streetlc,

    I wanted to make sure I’m following you here. You’ve created a custom shop page that doesn’t display the typical products/categories that you see on the default shop page. You’re interested in linking to the categories in the new page directly and wanted to use an HTML ID as an anchor.

    Based on the code and the URL you posted, that should scroll the shop page down so that the <h2> tag with that ID is at the top of the page. I’m assuming that nameofthelink is unique for each H2. If it’s not, then that’s something you’ll want to change.

    If they are unique and it’s still not working, I would recommend running the page through an HTML validator to make sure there aren’t any errors that could be causing this.

    https://validator.w3.org/

    Hopefully, that’ll point you to the code that needs updating. If you still have trouble, let us know. It would be very helpful to get to see the code on the page too.

    Thanks

    Thread Starter streetlc

    (@streetlc)

    Hi,

    Yes, i modified the presentation of the shop page by displaying the product categories one below the other with a title and a description.

    Unfortunately now when I point a link to a category, it brings up the general store page (which shows all the categories).

    This is why I am looking to put an anchor.

    I confirm I have personalized the “id” for each H2 title.

    I used the HTML validator, but I have lots of CSS errors that I don’t understand.

    Can I send you the url of my page in private?

    Best regards,

    Hey @streetlc,

    Here’s one way you do this. Visit the page and then view the source code of the page in your browser. Copy the source code and go to https://gist.github.com and paste the code there. Then copy the URL it gives you and paste it here in your reply. I can then view the code and check it for you. After we’re finished, you can delete it from https://gist.github.com.

    Let me know and we’ll go from there.

    Thread Starter streetlc

    (@streetlc)

    Hello @3sonsdevelopment

    I made it as you ask, here is the link : https://gist.github.com/Streetlc/73c14af3b3e06569873f8fb342bde44f

    You can find the part i change in the archive-product.php with searching :

    <nav class=”nav_type_2″><ul id=”menu-menu-principal” class=”menu”><li class=” menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children menu-item-30486 “>

    Thank you in advance.

    Best regards,

    Thread Starter streetlc

    (@streetlc)

    Hello,

    I haven’t heard from you.

    Were you able to watch?

    Thanks.

    Best regards,

    3 Sons Development

    (@3sonsdevelopment)

    Hey @streetlc,

    My apologies, I missed the notification from your previous reply. I just pulled up the Gist you created. Thanks for doing that. This page has a huge amount of inline CSS, fonts, and images. The text of the file is 1.8 MB by itself. That’s a lot of overhead for each page load. If possible, it would be better to have these in external files. That way the browser can cache them and not need to load all of this on every page. Also the validator didn’t want to validate that much so there could still be some issues.

    All that said, I did find where an ID had been added for a product category. Looking at the HTML there, it’s set like this:

    
    id="”ebooks”"
    

    There’s a set of straight quotes (good) surrounded by a set of curly quotes (bad). What you’ll want to do is make sure that each ID only has a set of straight quotes surrounding it. With that you can set up links to sections of the page.

    If you still have trouble, let me know.

    Thanks

    Thread Starter streetlc

    (@streetlc)

    Hello @3sonsdevelopment ,

    I suspected that you would make this remark on the content of the source code which surprised me too.

    I think it’s my theme that generates such an overload because personally I did nothing at this level.

    Do you think this can be my theme?
    Otherwise I don’t understand where it comes from.

    Ok thank you for the details, I will try to improve that.

    3 Sons Development

    (@3sonsdevelopment)

    Hey @streetlc,

    It could very well be the theme creating all of the CSS and inline images. It’s not the default way of doing things in WordPress so it’s either a theme or plugin that’s making that happen. You could try a bit of troubleshooting by switching themes and disabling plugins to see if you can find the exact source.

    Let me know if you have any questions.

    3 Sons Development

    (@3sonsdevelopment)

    Hey @streetlc,

    It’s been a while since we heard back from you, so I’m going to close out this thread now. If you have any questions, feel free to open up a new one.

    Cheers

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Php link anchor (woocommerce)’ is closed to new replies.