The issue with your query is that new WP_Query($query_string,$args);
is not correct syntax, however, creating a new WP_Query
is not the way to do what you want. See the codex page for pre_get_posts
for the correct way to modify the main query.
I assume by setting posts per page to 999, you want to show all posts, so just use -1
instead to remove the limit from the query. This would go in your theme’s functions.php
file:
function wpa90381_category_query( $query ) {
if ( $query->is_category() && $query->is_main_query() ) {
$query->set( 'posts_per_page', -1 );
$query->set( 'orderby', 'name' );
}
}
add_action( 'pre_get_posts', 'wpa90381_category_query' );
Related Posts:
- Display one latest post from multiple categories
- How to query post like normal search would do. within search.php page
- Set colors depending on category
- Pagination on category.php and tag.php not working
- Posts of specific category on page and excluded from index.htm
- Get posts from sites in Multisite?
- Get all categories and posts in those categories
- How To Modify The Loop in archives.php To Have 11 Posts Per Page and CSS Styling
- Combine two taxonomies in a hierarchical tree
- How to get posts from two categories with WP_Query?
- Group WP_Query by category
- Exclude categories from search query
- How can I reduce the number of database query calls for this custom homepage?
- WP_Query not looking at child category
- Get page content by category or tag
- Using categories & “stickyness” together
- Does the ‘cat’ argument in query_posts fetch posts from subcategories as well as the given ID?
- List posts by category exclude current post
- Excluding posts from a category but only if they’re not in multiple categories
- What could be causing my wp_query pagination to break?
- Display only the latest post from multiple categories
- Custom query with category exclusion and post-meta “whitelist”
- Exclude most recent posts from specific category in wp_query()
- Select category in custom query
- How to Check if a Child Category is Being Queried
- Return category slug / title from category ID
- How to show only one post for each categories of taxonomy of custom post that contains a specific custom field
- How to run WP_Query to retrieve attachments to posts only from a particular category?
- How to query posts from specific authors and categories using WP_query?
- Exclude category from loop not working
- “NOT ONLY IN” taxonomy query operator?
- How to show in search results posts with a particular tag in a particular category?
- Custom WP_Query for current category (in category.php)?
- List Posts by Category for a Non-Zero, Non-NULL Custom Field Value?
- getting content from main domain to sub-domain using category and WP_Query
- WP_Query() returns null when results exist!
- Ignoring a category in WP_Query still shows the links in next_post_link()?
- 3 Columns, 3 Categories, One Archive, and Pagination
- Five posts from a category in footer
- Post count for category and tag
- Enter a variable in the ‘category_name’ parameter
- Checking for two categories in query_posts
- Query Posts Exclude Entire Category
- how to query posts and auto assign category if post title has keyword
- How do I call posts with a certain tag?
- Modify WordPress SQL Query to pull from within a category
- query order by category
- Get link which associated with a specific category and tag
- Filtering out child category posts from parent category archive not working
- Multiple Loops on category.php with pagination on last loop
- How to get latest posts from each category in regular order
- change recent posts based on category
- Order by category titles
- Have parent category contain only one post?
- How to remove specific categories from posts?
- List posts in alphabetical order
- Randomly load categories with latest post
- How do I query_posts in cat=1 AND not in cat=2
- List all posts in a category with query_post() function
- query_post order desc
- Exclude a category from a query that includes its parent category
- Display posts from a category
- Show the latest post from child category?
- Custom loop of a single category, cannot order by date. What am I missing?
- Problem with different query loops (and “main loop”) on category template page!
- query_posts not reading correct categories
- category__not_in and id values from variable
- Use premade array as categories in wp_query?
- Pagination for query_posts();
- Posts from a category on homepage with category archieves page default css
- function query_posts disabling current_page_menu class
- query_posts by category_name and custom taxonomy
- WP_Query – using category__and when one of the categories is 0
- More efficient way to list posts by category [duplicate]
- Adding a block with query in homepage
- Query posts by views on category page
- I need to exclude from a query a category and a few custom taxonomies
- Show multiple categories in query using redux framework variable
- Are term_taxonomy_id and term_id the same? [duplicate]
- Return category posts with WP_Query
- Using in ‘category_name’ in ‘$query->set();’?
- multiple values in an array for category__and does not work with WP_Query
- Custom Page Template Category loop not functioning correctly
- Retrieve post tags from from main wp_query
- wordpress taxonomy query posts
- PHP dynamical conditional post display
- how can i hide category?
- How can I use AJAX with check-box categories?
- Select posts that match multiple category names, must match all categories listed
- the_category() doesn’t working in wp_query loop
- Displaying links to all posts of the same category on the post page
- Post not found when filtered by category ID
- How to display the 5 latest post titles but allow only 1 in there of a specific category
- Exclude categories from postquery
- Sort posts alphabetically by category/custom taxonomy, insert divider between different types
- Show posts from category specified using a custom field
- query_post problem
- Add class to current post in query_post
- Filter products on category AND tag
- Different post slug based on archive