Ecommerce Shopify WordPress Discussion

How to limit the number of terms in WordPress custom taxonomy terms page

I'm creating theme for movies and TV series. So I have CPT named 'series' and custom Taxonomy named 'shoof_series' and custom terms(categories) for each series. when I created page template to display all terms (series) named (all-series.php) its works fine. but when trying to set how many terms to display ('posts_per_page' = 5) still display all terms in the page. I have tried this cod. <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $terms = get_terms( 'shoof_series' ); foreach( $terms as $term ) : $query = new WP_Query( array( 'posts_per_page' => 1, 'paged' => $paged, 'tax_query' => array( array( 'taxonomy' => 'shoof_series', 'terms' => $term->slug, 'field' => 'slug', 'hide_empty' => false, // default: true ) ) ) ); if( $query->have_posts() ): while( $query->have_posts() ) : $query->the_post(); ?> <div class="col"> //my codes </div> <?php endwhile; endif; endforeach; ?> <?php wpbeginner_numeric_posts_nav(); ?> and tried this one too <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $terms = get_terms( array( 'taxonomy' => 'shoof_series', 'hide_empty' => false, ) ); if ( empty( $terms ) || is_wp_error( $terms ) ) { return; } foreach( $terms as $term ) { ?> <div class="col"> //my codes </div> <?php $term->count; }?> <?php wpbeginner_numeric_posts_nav(); ?> both of codes work fine, but I cant set how many posts to display per page. so how can I do it?
Since WordPress 4.5+ you need to pass your custom taxonomy in an array… You can use the following arguments in a WP_Term_Query. To restrict the number of terms, use the number argument. So you can replace in your code: $terms = get_terms( 'shoof_series' ); with the following: $terms = get_terms( array( 'taxonomy' => 'product_cat', 'number' => 5, // Here set the desired number of terms ) );

February 4, 2024

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.