You can check for the existence of a variable, so you don’t overwrite it:
add_action( 'pre_get_posts', 'wpse7262_pre_get_posts' );
function wpse7262_pre_get_posts( &$wp_query )
{
if ( $wp_query->is_category() ) {
if ( ! array_key_exists( 'post_type', $wp_query->query_vars ) ) {
$wp_query->set( 'post_type', 'game' );
}
if ( ! array_key_exists( 'posts_per_page', $wp_query->query_vars ) ) {
$wp_query->set( 'posts_per_page', 9 );
}
}
}
Related Posts:
- Multiple WP_Query loops with Pagination
- Pagination returns 404 after page 20
- Pagination with WP_Query is buggy – working for some pages, but not the others
- Get the number of posts from the current page results
- Pagination with 5 posts per page
- Pagination/infinite scroll with WP_Query and multiple loops
- Pagination Not working on Home Page with 2 Query
- Pagination not working Search posts
- Transient pagination not working properly
- Injecting content with $wp_query->current_post restarts from zero on paged pages. How to inject content after X posts, regardless of pagination?
- Woocommerce custom loop to show all the products [closed]
- How to bring specific post to front of wordpress loop?
- Pagination stops at page 6
- Paginated HTML Sitemap
- Multiple WP_Query loops with Pagination Not Working
- Posts loop with pagination on a single post page
- Create ONE callback for all page templates, post filter queries + paginated pages, triggering pagination via AJAX
- Pagination is broken and I need help fixing it
- Storing query variable and then using wp_reset_query
- Create A Loop With A Variable Number of Posts For Each Bootstrap Row?
- Five posts from a category in footer
- posts_per_page not working for first page of pagination
- How do I get my custom query to work with search results after the first page?
- Stomping WP_Query in author archive to facilitate pagination with custom queries
- Second loop pagination changes URL, not content
- I am officially missing something about transient posts
- Query Not working as expected
- Paginate pages with dynamic query
- Function the_posts_pagination() not compatible with WP_Query arguments
- How can I have sticky posts while ALSO showing posts from a specific category using one WP_Query?
- Pagination inside the blog page not working
- Custom Query Pagination not working on static front page
- Paging works correctly on local version, but not live?
- Problem with custom WP_Query and underlying pagination/posts_per_page
- 2 Loops on one page – pagination of 2nd loop ignore array of excluded posts
- Pagination returns 404 after page 20
- custom query – offset to pagination
- Pagination not working with WP_QUERY
- No content found on page 2 of pagination with 1 post per page
- wp_query pagination links producing 404
- Loop being strainge
- Pagination in custom query not working [duplicate]
- Multiple loops on index page with sticky post and pagination
- Pagination problem with multiple loops on the same page
- WordPress Post Looping? [duplicate]
- Show number of posts AND number on current page (cannot make it work)
- Pagination only showed when no category is set in wp_query
- Can I force WP_Query to return no results?
- paginate_links() adds empty href to first page and previous link
- Too slow when using both ‘tax_query’ and ‘meta_query’ both in WP_Query
- Get array of posts from the current archive page loop
- How can I save an array from a random post sequence for later use?
- Pagination custom query
- In loop: posts have thumbnail AND other variables
- How to order category.php loop by ‘meta_value’?
- Add inline HTML to posts published within last 24hrs
- Add and in the header while looping over custom query in page template
- Pagination not working on static page
- How to change a custom query into a standard loop?
- wordpress query in header won’t reset and corrupts other loops
- 2 loops on page – one with orderby rand second orderby date
- Undefined WP_Query::has_posts()?
- How to use WP_Query to display many posts?
- Counter problem, infinite loop when post_per_page equals X
- How to get all unique categories for posts in loop?
- Using the_post_thumbnail resets current loop item ID
- Order by empty custom field
- Cutom wp_query for geolocation search, pagination not working
- WP Query to have sticky posts first, with pagination and having a joint ‘posts per page’ arg with main loop
- New WP_Query loop in admin causes problems
- Need to convert string of term ids into comma separated integers for use in an arguments array
- How to use WP_Query() on single.php?
- Pagination on category.php and tag.php not working
- difference between querying database and using the loop
- Loop increase in while loop not working
- posts archive page – closing WP_Query loop correctly [closed]
- Yoast primary category query modification
- AJAX Breaking Offset Argument In WP Query
- Continue or break the while loop
- Pagination in html table is not working
- Function using get_posts() with tax_query not working when called from functions.php
- WP_query paged pagination with excluded category still counts it
- How to make the ‘request’ filter work?
- How do I stop the same post showing multiple times in a archive?
- Pagination unique to a widget
- Why pagination is not working with tax_query param?
- paginate_links method doesn’t show second page of my custom wp_query
- Wp_Query Post per page not working?
- how to get custom attachment url?
- WP_Query & Duplicate entries
- Calling a function with WP_Query only ever brings the first result
- query_posts() doesn’t seem to be called in my page
- Create multiple sections for all categories and then queries all the posts for each of those categories
- Filter WP_Query output before it is accessed (pre_get_posts)?
- Next / previous posts link doesn’t show up with Posts 2 Posts
- WordPress Numeric Pagination with Query String [duplicate]
- Carousel Loop only duplicating
- How to show featured post first, then separate loop for other posts
- error with $query->have_posts()
- Query All Posts: Either Display Most Recent or One with Particular ACF Value Chosen