[Support request] "Previous" and "Next" buttons in Woocommerce

Home Forums Support [Support request] "Previous" and "Next" buttons in Woocommerce

Home Forums Support "Previous" and "Next" buttons in Woocommerce

Viewing 15 posts - 1 through 15 (of 26 total)
  • Author
    Posts
  • #636836
    Alberto

    Hi!

    I would like to know if there is any way to place “previous” and “following” buttons on the Woocommnerce product pages, so that you can navigate from one product to another without having to return to the product category page.

    Thank you in advance.

    #636901
    David
    Staff
    Customer Support
    #636920
    Alberto

    Hello David! Thank you very much for your reply.

    I would appreciate it if you could indicate where I should place those codes within Generatepress.

    Thank you very much!

    #636924
    David
    Staff
    Customer Support

    So the first code is PHP:

    https://docs.generatepress.com/article/adding-php/
    If you’re not using a Child theme i would suggest the Code Snippets plugin, a link to which is in the above article

    Second is CSS:
    https://docs.generatepress.com/article/adding-css/

    #637055
    Alberto

    David.

    I have placed the php code using the Code Snippets plugin. I also placed the additional CSS from Customize> Additional CSS, however the previous and next arrows do not appear on the Woocommerce product page …

    I think I followed the steps correctly …

    I have to win something more from Generapress?

    Thank you in advance.

    #637084
    David
    Staff
    Customer Support

    Aah ok, that code works by skipping through the Product Categories, which it looks like your products don’t have any?

    Try adding a base category to some of the products and see if that works.

    #637101
    Alberto

    All the products belong to a category (you can see it from the accordion menu on the right). I have the breadcrumb disabled from Generatepress, although activating it does not make any difference either …

    #637361
    Tom
    Lead Developer
    Lead Developer

    That’s weird.

    In your PHP code, find this line:

    echo $previous;

    On the line above it, do this:

    var_dump($previous);

    So it should look like this:

    var_dump($previous);
    echo $previous;

    That will output some debugging data where the links should show up. Can you share that data with me?

    #637372
    Alberto

    Hello Tom.

    After placing the code, it now appears, on the left side NULL

    #637396
    Tom
    Lead Developer
    Lead Developer

    Weird, so that core WP function isn’t working..

    Try this:

    add_action( 'woocommerce_before_single_product_summary', 'tu_prev_next_product' );
    function tu_prev_next_product(){
        echo '<div class="prev_next_buttons">';
            next_post_link( '%link', '&larr; Previous', true, false, 'product_cat' );
            previous_post_link( '%link', 'Next &rarr;', true, false, 'product_cat' );
        echo '</div>';  
    }
    #637612
    Alberto

    Hello, good morning Tom.

    I changed the code I had for this one that you passed me and the previous and next arrows still do not show …

    I no longer know what the error may be.

    Thank you very much for your help.

    #638201
    Tom
    Lead Developer
    Lead Developer
    #638204
    Alberto

    Tom.

    Unfortunately, it still does not work

    #638286
    Tom
    Lead Developer
    Lead Developer

    Hmm, this has me stumped! Let me do some testing – I’ll get back to you.

    #638497
    Alberto

    Ok, thank you very much and I await your response.

Viewing 15 posts - 1 through 15 (of 26 total)
  • You must be logged in to reply to this topic.