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
- Multiple queries and pagination
- difference between querying database and using the loop
- If have posts a week old, display, else display a different loop
- WP_Query – Adding “offset” posts to the end of the loop
- How to make posts unqueryable/unpublish posts where ACF relationship field is an unpublished post? [closed]
- Conditional operator OR not working with custom fields
- Pagination on template page for custom query redirecting to index.php
- Getting blog pagination to work on page set as front page
- Loop increase in while loop not working
- Create a loop on my pages with new “WP_Query”
- Get posts that do not have the same tags as current
- I need help using pre_get_comments to limit comments in the comments admin screen
- posts archive page – closing WP_Query loop correctly [closed]
- Create a page template for “top rated posts” but show full content and not just a list
- has_excerpt() not working inside wp_query
- wp_query is showing posts from other categories
- Daily drip of posts – based on user ‘startData’ – ordered oldest to newest
- How to add tax_query to $args with concatenation
- Should I reset $wp_query?
- Meta query compare for ID’s greater than specific ID
- Exclude a Woocommerce product from WP_Query
- WP ForLoop to compare meta information of posts to determine what post to display
- Yoast primary category query modification
- AJAX Breaking Offset Argument In WP Query
- WP_QUERY wrong ammount of posts
- How to add sort order to incremented and paginated category loop
- How does WP generate the default $query in WP_Query based on the URL?
- Continue or break the while loop
- How to filter query loop block with a search string from the query parameters
- WP_Query – How to get all posts of specific days of week by custom field date?
- inserting content of 1 Post to in another with a template hierarchy
- how to get category`s slug in WP_Query loop?
- Loop posts based on permalink term
- Page navigation doesn’t seem to work when I add offset?
- Save (and exclude) posts from loop to use in another loop on page
- Get all posts with empty meta_value
- How to split a post and intercalate elements from a loop
- How to remove only the latest sticky post from the loop
- Expecting statement error from php loop using ACF plugin
- Loop 3 posts column wise and continue the loop into same columns
- How I can repeat 2 HTML templates in a WordPress Query?
- PHP – Loop custom post type categories within jQuery Tabs
- Check if a post has term inside loop
- How to create a widget like this?
- Notice thrown when creating numeric pagination on custom query
- How do I sort this custom list of sticky posts
- WP_Query with one category in args shows other categories
- Query only displays one page_id
- Pagination in html table is not working
- Content not displaying on paginated page
- How to Order By Two Custom Fields?
- Display specific page (that is child) content on parent page
- Different Loop for tag pages?