W3Counter

Customize the number of Teasers per page/category/archive

September 12, 2010

This feature was added in Thesis 1.8 after the initial Thesis 1.8 release. Make sure you download the latest copy of Thesis before trying this out.

Thesis 1.8 introduces a new filter, which enables us to modify the number of teasers that appear on our home page or any other page.

add_filter('thesis_is_teaser', 'thesify_is_teaser');
function thesify_is_teaser($is_teaser)
{
    static $post_count;
    $post_count = $post_count ? $post_count + 1 : 1;
   
    // show 4 feature posts, the rest as teasers on the
    // category archives for Lorem
    if( is_category('Lorem') )
    {
        return $post_count > 4;
    }
    // show 2 feature posts, the rest as teasers on the home page
    if( is_home() )
    {
        return $post_count > 2;
    }
    // inverts the order of feature posts / teasers on the category
    // archives for 'Ipsum'. first 4 posts become teasers, rest featured
    if( is_category('Ipsum') )
    {
        return $post_count <= 4;
    }
    // return the defaults for the rest
    return $is_teaser;
}

{ 1 comment… read it below or add one }

Bruno Amaral September 18, 2010 at 2:30 am

I tried to use this bit of code but for some reason it did not change the output.

The thesis custom loop feature is an alternative, it allowed me to builda teaser-only wordpress loop.

Reply

Leave a Comment

Next post: