Archive Page(s) Post Count Not editable
-
What I am looking to do is have a different number of post on the home page (5 post) than on the dynamically generated paginated archive pages (10 post).
As far as I can tell the “index.php” uses a theme specific template part “content.php” and I think that when wordpress created the dynamically generated paginated archive pages it also uses “content.php” to create the chronological archive pages, which in tern makes the following code that I have in my “functions.php” not respond as expected.
is_home() and is_category() work as expected, however is_archive() seems to be ignored, and only displays 5 post.
function my_post_queries( $query ) { // do not alter the query on wp-admin pages and only alter it if it's the main query if (!is_admin() && $query->is_main_query()){ // alter the query for the home and category pages if(is_home()){ $query->set('posts_per_page', 5); } elseif(is_category()){ $query->set('posts_per_page', 10); } elseif(is_archive()){ $query->set('posts_per_page', 10); } } } add_action( 'pre_get_posts', 'my_post_queries' );
Any help is greatly appreciated.
- The topic ‘Archive Page(s) Post Count Not editable’ is closed to new replies.