Site logo

Archived topic

"Previous" and "Next" buttons in Woocommerce

25 replies · Started by Alberto on July 31, 2018

Viewing posts 1–15 of 26

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.

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!

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.

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.

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 ...

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?

Hello Tom.

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

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>';  
}

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.

Tom.

Unfortunately, it still does not work

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

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

This archived topic is closed to new replies.