WordPress.org

Support

Support » Plugins and Hacks » [Plugin: cbnet Different Posts Per Page] Add a category to the plugin

[Plugin: cbnet Different Posts Per Page] Add a category to the plugin

Viewing 1 replies (of 1 total)
  • Plugin Author Chip Bennett
    Theme Review Admin

    @chipbennett

    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.

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: cbnet Different Posts Per Page] Add a category to the plugin’ is closed to new replies.