cbnet Different Posts Per Page
Add a category to the plugin (2 posts)

  1. aground
    Posted 4 years ago #

    How do we add a category to the list of pages that can have numbered posts. I see how to adjust the number of posts, but we need to add a category to the list and I can't find that option.
    Eddie Jones


    Never mind. Found it. Was at the bottom of the plug in page. Had to think on it some, but I got it. Pre she ate it.

  2. Chip Bennett
    Theme Review Admin
    Plugin Author

    Posted 3 years ago #

    I've re-written the Plugin from the ground up, as version 2.0. It should be more easily extensible now, though I need to put a bit more thought into how to facilitate targeting specific taxonomy terms (including specific categories).

    Once I figure out the best way to handle that, I'll release another update. Until then, you can use a simple filter of your own to control the number of posts per page of your specific category.

    Assuming the category is foobar and that you want to display 5 posts per page, add the following to a site Plugin, or to functions.php:

    function aground_filter_pre_get_posts( $query ) {
        if ( is_main_query() && is_category( 'foobar' ) ) {
            $query->set( 'posts_per_page', '5' );
        return $query;
    add_action( 'pre_get_posts', 'aground_filter_pre_get_posts' );

    And that should be all you need. Just change foobar and 5 as appropriate.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • cbnet Different Posts Per Page
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic