As @StephenHarris pointed out there’s also the pre_get_posts
filter.
function hwl_home_pagesize( $query )
{
if ( is_category( 9 ) )
{
// If you want "posts per page"
$query->query_vars['posts_per_page'] = 1;
return;
}
if ( is_category( 'movie' ) )
{
// If you want "showposts"
$query->query_vars['showposts'] = 50;
return;
}
}
add_action( 'pre_get_posts', 'hwl_home_pagesize', 1 );
Example altered from Codex example.
Related Posts:
- How to limit posts by category
- How can i limit the number of posts created per category?
- Excluding category from post navigation in WordPress?
- Different post sort order within different categories
- How to add metabox for post of specific category
- Convert custom fields to post categories
- How to get Category Id from Post Id ?
- Query posts from current year
- Exclude category on blog list page
- Show One Category on Post
- How to choose a sort order (for posts) per category? (ideally when creating a new category)
- WordPress Child Category Display All Posts
- Do I use custom post type or something else?
- What Defines What Category A Post Picks (if in multiple)
- Limit function to specific post category
- Add Category name to Post Title (h1)
- Display posts in alphabetical order for a particular category
- How to make search for the custom post type?
- Category Template: Need to display different content on first page of archives
- How to automatically apply a category based on the post title?
- Direct link to “New post” in specific category?
- Display post category in foreach loop with category link
- Using permalinks, category slugs, and tag slugs
- How do I retrieve then print the currently viewed sub categories?
- Get user categories with most posts in it
- Get attachments for posts that belongs to a specific category
- How can I setup a relationship using categories in WordPress?
- Related posts by category not working right
- How to list recent posts in a wp nav menu?
- Dynamic dependent Dropdown lists for categories, sub-categories and posts
- Listing Specific Categories from Current Post with Depth
- How to display two blog categories as separate sections on one page?
- How to Mysql select a list of posts with meta_values AND all relevant categories?
- get_the_category listing in hierarchial order
- get posts from Custom Post Type & Category
- Give posts a particular template based on the assigned category
- Show posts on front page only
- Post-Archive like a page in a specific subdirectory
- Post is in descendant category not working in home.php
- How to get posts ordered by using their categories?
- Hide parts of the post content after typing it’s name or searching it by category
- SQL Bulk Move old posts by one author to another category
- How to display only one category in a custom post type?
- load more posts by category
- Get only X number of categories
- Display Related Posts by Category in Random
- inserting a category into post
- Getting posts from some categories plus some individual posts
- Change layout of post depending on category
- How to show beneath posts the full category path?
- latest post showing up twice on posts page
- wp_list_categories() Exclude All Categories Except One
- Display Current Posts Category (with the most posts)?
- Allow / show post comments in category pages
- Only the most recent post is showing on my category page (working on localhost, not live site)
- Display default matabox of posts(add category) wordpress
- How display related post only in Default category on single
- ACF date picker to trigger category change
- Get category slug of the Parent category of a Product
- How to get tags when using publish_post
- Limit front-end submitted posts by role
- exclude particular category in api
- How do you change the permalink for posts for a single category?
- Posts are not displaying on their category and tag page
- Make categories appear random
- how to create a category with wp_insert_post and post_category
- How to add a block to a category page?
- If user has 1 post then dont let him create new one [closed]
- How to make a page show posts only from specific categories without editing php files
- Get posts from category from custom query
- Post Category link is same with Page link
- How to show posts ordered by random [duplicate]
- How to Get Position of a Post from a category and tag
- Display new posts categories in separated divs
- Querying posts from current category, using a variable as array argument
- Add Categories To Custom Post
- Query posts from newest category
- Precedence of page permalinks over woocommerce product category links?
- Display Posts by Categories
- Ajax – Post Categories and Load More
- Need help writing loop to display posts by categories in separate divs
- Edit Posts Page but not category specific pages?
- Add category selection to function request
- Multiple Post Repeat for Related Post Loop by Category
- Show Post number of specific Category
- How to organise post by category and date
- Show post if in category
- How to display custom content in post with category XXX
- Displaying categories items among posts
- Displaying different posts Via wp_list_categories()
- Is possible to create a custom link that creates a post that’s already categorized?
- Is it possible to have different header style blog titles in different categories?
- Category pages vs single post pages
- How to display subcategory articles in the category view?
- Display ONLY Latest Post From Several Categories
- How do we display a certain category type on a page while hiding all others?
- Show all posts in category
- Polylang – display one post into 3 categories with different lang [closed]
- Export Posts Without Categories In An XML File
- wordpress category Description not allowed tag