Skip to main content
added 1 characters in body
Source Link
Brad Dalton
  • 7k
  • 2
  • 36
  • 47

The problem using the native Reading Settings is that it effects the main loop.

What you can do is use pre_get_posts with a conditional tag to control how many posts in a CPT or Taxonomy archive are displayed:

You can modify this code with the conditional for your CPT or taxonomy archive page:

add_action( 'pre_get_posts', 'wpsites_taxonomy_archive_limit' );
function wpsites_taxonomy_archive_limit( $query ) {

if( $query->is_main_query() && !is_admin() && is_tax( 'book''books' ) ) {
    $query->set( 'posts_per_page', '8' );
}

}

The above code displays 8 posts in the custom taxonomy type archive, book.

For a custom post type archive, use something like this:

add_action( 'pre_get_posts', 'wpsites_cpt_archive_limit' );
function wpsites_cpt_archive_limit( $query ) {

if( $query->is_main_query() && !is_admin() && is_post_type_archive( 'book' ) ) {
    $query->set( 'posts_per_page', '8' );
}

}

Source http://codex.wordpress.org/Conditional_Tags#A_Taxonomy_Page

The problem using the native Reading Settings is that it effects the main loop.

What you can do is use pre_get_posts with a conditional tag to control how many posts in a CPT or Taxonomy archive are displayed:

You can modify this code with the conditional for your CPT or taxonomy archive page:

add_action( 'pre_get_posts', 'wpsites_taxonomy_archive_limit' );
function wpsites_taxonomy_archive_limit( $query ) {

if( $query->is_main_query() && !is_admin() && is_tax( 'book' ) ) {
    $query->set( 'posts_per_page', '8' );
}

}

The above code displays 8 posts in the custom taxonomy type archive, book.

For a custom post type archive, use something like this:

add_action( 'pre_get_posts', 'wpsites_cpt_archive_limit' );
function wpsites_cpt_archive_limit( $query ) {

if( $query->is_main_query() && !is_admin() && is_post_type_archive( 'book' ) ) {
    $query->set( 'posts_per_page', '8' );
}

}

Source http://codex.wordpress.org/Conditional_Tags#A_Taxonomy_Page

The problem using the native Reading Settings is that it effects the main loop.

What you can do is use pre_get_posts with a conditional tag to control how many posts in a CPT or Taxonomy archive are displayed:

You can modify this code with the conditional for your CPT or taxonomy archive page:

add_action( 'pre_get_posts', 'wpsites_taxonomy_archive_limit' );
function wpsites_taxonomy_archive_limit( $query ) {

if( $query->is_main_query() && !is_admin() && is_tax( 'books' ) ) {
    $query->set( 'posts_per_page', '8' );
}

}

The above code displays 8 posts in the custom taxonomy type archive, book.

For a custom post type archive, use something like this:

add_action( 'pre_get_posts', 'wpsites_cpt_archive_limit' );
function wpsites_cpt_archive_limit( $query ) {

if( $query->is_main_query() && !is_admin() && is_post_type_archive( 'book' ) ) {
    $query->set( 'posts_per_page', '8' );
}

}

Source http://codex.wordpress.org/Conditional_Tags#A_Taxonomy_Page

added 12 characters in body
Source Link
Brad Dalton
  • 7k
  • 2
  • 36
  • 47

The problem using the native Reading Settings is that it effects the main loop.

What you can do is use pre_get_posts with a conditional tag to control how many posts in a CPT or Taxonomy archive are displayed:

You can modify this code with the conditional for your CPT or taxonomy archive archive page:

add_action( 'pre_get_posts', 'wpsites_taxonomy_archive_limit' );
function wpsites_taxonomy_archive_limit( $query ) {

if( $query->is_main_query() && !is_admin() && is_tax( 'book' ) ) {
    $query->set( 'posts_per_page', '8' );
}

}

The above code displays 8 posts in the custom taxonomy type archive, book.

For a custom post type archive, use something like this:

add_action( 'pre_get_posts', 'wpsites_cpt_archive_limit' );
function wpsites_cpt_archive_limit( $query ) {

if( $query->is_main_query() && !is_admin() && is_post_type_archive( 'book' ) ) {
    $query->set( 'posts_per_page', '8' );
}

}

Source http://codex.wordpress.org/Conditional_Tags#A_Taxonomy_Page

The problem using the native Reading Settings is that it effects the main loop.

What you can do is use pre_get_posts with a conditional tag to control how many posts in a CPT archive are displayed:

You can modify this code with the conditional for your CPT or taxonomy archive archive page:

add_action( 'pre_get_posts', 'wpsites_taxonomy_archive_limit' );
function wpsites_taxonomy_archive_limit( $query ) {

if( $query->is_main_query() && !is_admin() && is_tax( 'book' ) ) {
    $query->set( 'posts_per_page', '8' );
}

}

The above code displays 8 posts in the custom taxonomy type archive, book.

For a custom post type archive, use something like this:

add_action( 'pre_get_posts', 'wpsites_cpt_archive_limit' );
function wpsites_cpt_archive_limit( $query ) {

if( $query->is_main_query() && !is_admin() && is_post_type_archive( 'book' ) ) {
    $query->set( 'posts_per_page', '8' );
}

}

Source http://codex.wordpress.org/Conditional_Tags#A_Taxonomy_Page

The problem using the native Reading Settings is that it effects the main loop.

What you can do is use pre_get_posts with a conditional tag to control how many posts in a CPT or Taxonomy archive are displayed:

You can modify this code with the conditional for your CPT or taxonomy archive page:

add_action( 'pre_get_posts', 'wpsites_taxonomy_archive_limit' );
function wpsites_taxonomy_archive_limit( $query ) {

if( $query->is_main_query() && !is_admin() && is_tax( 'book' ) ) {
    $query->set( 'posts_per_page', '8' );
}

}

The above code displays 8 posts in the custom taxonomy type archive, book.

For a custom post type archive, use something like this:

add_action( 'pre_get_posts', 'wpsites_cpt_archive_limit' );
function wpsites_cpt_archive_limit( $query ) {

if( $query->is_main_query() && !is_admin() && is_post_type_archive( 'book' ) ) {
    $query->set( 'posts_per_page', '8' );
}

}

Source http://codex.wordpress.org/Conditional_Tags#A_Taxonomy_Page

Source Link
Brad Dalton
  • 7k
  • 2
  • 36
  • 47

The problem using the native Reading Settings is that it effects the main loop.

What you can do is use pre_get_posts with a conditional tag to control how many posts in a CPT archive are displayed:

You can modify this code with the conditional for your CPT or taxonomy archive archive page:

add_action( 'pre_get_posts', 'wpsites_taxonomy_archive_limit' );
function wpsites_taxonomy_archive_limit( $query ) {

if( $query->is_main_query() && !is_admin() && is_tax( 'book' ) ) {
    $query->set( 'posts_per_page', '8' );
}

}

The above code displays 8 posts in the custom taxonomy type archive, book.

For a custom post type archive, use something like this:

add_action( 'pre_get_posts', 'wpsites_cpt_archive_limit' );
function wpsites_cpt_archive_limit( $query ) {

if( $query->is_main_query() && !is_admin() && is_post_type_archive( 'book' ) ) {
    $query->set( 'posts_per_page', '8' );
}

}

Source http://codex.wordpress.org/Conditional_Tags#A_Taxonomy_Page