No results found. Try again with different words?

Search must be at least 3 characters.

Display Products from Same Category with Navigation

Sidebar Image

Did not find a solution? We are here to help you succeed.

If you want to display WooCommerce products from the same category one after the other, this article is for you.

By default, when you click on the “Next” button or icon, the next product will be displayed based on the published date.

But, the filter provided in this article will help you display the next/previous product from the same category based on the product’s published date.  

For example – If category A has 10 products, then starting from 1st product next link will display all 10 products. After 10 products the next link will be disabled.

Paste the following filter in the child theme’s functions.php file. 

function astra_woo_product_previous_post_nav( $args ) {

    $args = array(
        'format'         => '%link',
        'link'           => '',
        'in_same_term'   => true,
        'excluded_terms' => '',
        'taxonomy'       => 'product_cat',
    );
    return $args;
    }
    add_filter( 'astra_woo_product_previous_post_nav_args', 'astra_woo_product_previous_post_nav' );
    
    function astra_woo_product_next_post_nav( $args ) {
    
    $args = array(
        'format'         => '%link',
        'link'           => '',
        'in_same_term'   => true,
        'excluded_terms' => '',
        'taxonomy'       => 'product_cat',
    );
    return $args;
    }
    add_filter( 'astra_woo_product_next_post_nav_args', 'astra_woo_product_next_post_nav' );

From the above filter link argument can be updated as follows –

link: If you want to update the next and previous link icons for navigation, update this argument. You can use  <i> tag from various font libraries.

You would then need to upload the respective font library to Astra. 

Here is the article that shows how Font Awesome Icons can be used with Astra. 

That’s it! For any doubts, feel free to open a support ticket below.

Was this article helpful?
Sidebar Image

Did not find a solution? We are here to help you succeed.

Related Docs

Join 1,653,898+ Happy Site Owners Using Astra

Whether you are a beginner, small business owner, or professional web developer, Astra provides all the tools you need to easily build your beautiful WordPress website.

Download is Just A Click Away!

Membership Retention Checklist Download

REWIND

YEAR IN REVIEW

Download is Just A Click Away!

Enter your email address and be the first to learn about updates and new features.

Download Free Astra Theme - Modal Popup Form
Scroll to Top
Now choose your preferred
page builder addon
Choose your preferred page builder addon

Download is Just A Click Away!

Enter your email address and be the first to learn about updates and new features.

Download Free Astra Theme - Modal Popup Form