Set Posts_per_page by Taxonomy while maintaining Pagination in Wordpress

$option_posts_per_page = get_option( 'posts_per_page' ); add_action( 'init', 'my_modify_posts_per_page', 0); function my_modify_posts_per_page() { add_filter( 'option_posts_per_page', 'my_option_posts_per_page' ); } function my_option_posts_per_page( $value ) { global $option_posts_per_page; if ( is_tax( 'portfolio-category') ) { return 2; } else { return $option_posts_per_page; } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.