Skip to main content
deleted 2 characters in body
Source Link
henrywright
  • 3.1k
  • 6
  • 39
  • 65

You should use the pre_get_posts filter for this. For example, you could do this in your theme's functions.php file:

function limit_category_posts( $query ) {
    if ( $query->is_archive() ) {

        // Do not do this for the date or category archives.
        if ( $query->is_date() || $query->is_category() )
            return $query;
        
        if ( $query->query_vars['cat'] == '8'8 ) {
            $query->set( 'posts_per_page', 2 );
        }
    }
    return $query;
}
add_filter( 'pre_get_posts', 'limit_category_posts' );

You should use the pre_get_posts filter for this. For example, you could do this in your theme's functions.php file:

function limit_category_posts( $query ) {
    if ( $query->is_archive() ) {

        // Do not do this for the date or category archives.
        if ( $query->is_date() || $query->is_category() )
            return $query;
        
        if ( $query->query_vars['cat'] == '8' ) {
            $query->set( 'posts_per_page', 2 );
        }
    }
    return $query;
}
add_filter( 'pre_get_posts', 'limit_category_posts' );

You should use the pre_get_posts filter for this. For example, you could do this in your theme's functions.php file:

function limit_category_posts( $query ) {
    if ( $query->is_archive() ) {

        // Do not do this for the date or category archives.
        if ( $query->is_date() || $query->is_category() )
            return $query;
        
        if ( $query->query_vars['cat'] == 8 ) {
            $query->set( 'posts_per_page', 2 );
        }
    }
    return $query;
}
add_filter( 'pre_get_posts', 'limit_category_posts' );
added 14 characters in body
Source Link
henrywright
  • 3.1k
  • 6
  • 39
  • 65

You should use the pre_get_posts filter for this. For example, you could do this in your theme's functions.php file:

function limit_category_posts( $query ) {
    if ( $query->is_archive() ) {

        // Do not do this for the date or category archives.
        if ( $query->is_date() || $query->is_category() )
            return $query;
        
        if ( is_category($query->query_vars['cat'] '8'== )'8' ) {
            $query->set( 'posts_per_page', 2 );
        }
    }
    return $query;
}
add_filter( 'pre_get_posts', 'limit_category_posts' );

You should use the pre_get_posts filter for this. For example, you could do this in your theme's functions.php file:

function limit_category_posts( $query ) {
    if ( $query->is_archive() ) {

        // Do not do this for the date or category archives.
        if ( $query->is_date() || $query->is_category() )
            return $query;
        
        if ( is_category( '8' ) ) {
            $query->set( 'posts_per_page', 2 );
        }
    }
    return $query;
}
add_filter( 'pre_get_posts', 'limit_category_posts' );

You should use the pre_get_posts filter for this. For example, you could do this in your theme's functions.php file:

function limit_category_posts( $query ) {
    if ( $query->is_archive() ) {

        // Do not do this for the date or category archives.
        if ( $query->is_date() || $query->is_category() )
            return $query;
        
        if ( $query->query_vars['cat'] == '8' ) {
            $query->set( 'posts_per_page', 2 );
        }
    }
    return $query;
}
add_filter( 'pre_get_posts', 'limit_category_posts' );
added 2 characters in body
Source Link
henrywright
  • 3.1k
  • 6
  • 39
  • 65

You should use the pre_get_posts filter for this. For example, you could do this in your theme's functions.php file:

function limit_category_posts( $query ) {
    if ( $query->is_archive() ) {

        // Do not do this for the date or category archives.
        if ( $query->is_date() || $query->is_category() )
            return $query;
        
        if ( is_category( '8' ) ) {
            $query->set( 'posts_per_page', 2 );
        }
    }
    return $query;
}
add_filter( 'pre_get_posts', 'limit_category_posts' );

You should use the pre_get_posts filter for this. For example, you could do this in your theme's functions.php file:

function limit_category_posts( $query ) {
    if ( $query->is_archive() ) {

        // Do not do this for the date or category archives.
        if ( $query->is_date() || $query->is_category() )
            return $query;
        
        if ( is_category( '8' ) {
            $query->set( 'posts_per_page', 2 );
        }
    }
    return $query;
}
add_filter( 'pre_get_posts', 'limit_category_posts' );

You should use the pre_get_posts filter for this. For example, you could do this in your theme's functions.php file:

function limit_category_posts( $query ) {
    if ( $query->is_archive() ) {

        // Do not do this for the date or category archives.
        if ( $query->is_date() || $query->is_category() )
            return $query;
        
        if ( is_category( '8' ) ) {
            $query->set( 'posts_per_page', 2 );
        }
    }
    return $query;
}
add_filter( 'pre_get_posts', 'limit_category_posts' );
added 104 characters in body
Source Link
henrywright
  • 3.1k
  • 6
  • 39
  • 65
Loading
Source Link
henrywright
  • 3.1k
  • 6
  • 39
  • 65
Loading