WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. aground
    Member
    Posted 2 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.
    Thanks.
    Eddie Jones

    http://wordpress.org/extend/plugins/cbnet-different-posts-per-page/

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

  2. Chip Bennett
    Theme Review Admin
    Plugin Author

    Posted 1 year 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

About this Topic