Try adding this code to functions.php
file:
add_action('pre_get_posts', 'ad_filter_categories');
function ad_filter_categories($query) {
if ($query->is_main_query() && is_home()) {
$query->set('category_name','news, uncategorized');
}
}
category_name
is the slug or the nicename of the category. Add a comma separated list of the categories you wish to include.
Related Posts:
- Category page doesn’t use category.php, instead it redirects to homepage
- Arrange posts by date in front page
- How to show only the name of one category above each posts in frontpage?
- I need advice on how to structure the categories according to the layout i have
- Categories not posts at the frontpage
- Get all categories and posts in those categories
- How to display non-hierarchical taxonomy as terms with checkboxes?
- Combine two taxonomies in a hierarchical tree
- How to filter categories by custom field?
- get_terms name__like list categories according to letter
- Adding Colorpicker Field To Category
- Add extra fields to Add New Category page
- get_categories returns an array with one category
- Different templates for parent and children categories/taxonomies
- How to make a relationship between books and authors?
- Create a full width responsive header image per page
- How to create tabled index of posts in a certain category
- Remove child products from woocommerce category page [closed]
- Display comments on a comment page without form
- Plural Category Base Slug On Category Archive Page
- WP 3.0.5: Best way to add custom metaboxes for post categories?
- How do I view a feed consisting of posts from multiple categories?
- Marking old posts as no longer relevant
- Unpublish all posts in a category
- Any way to assign Post Categories and Tags to Links?
- Add class to items in wp_list_categories()
- How is the single category page called and how does it know which posts to show?
- How to create a page that shows posts from multiple categories
- Is it possible to select and edit the way the most recent post from a certain category is displayed on the page?
- Problem with wp_create_category
- Should the actual /category/ directory be 404? Is that normal WP behaviour
- Redirect category to url with /category
- I Cannot Create New Category
- Archive.php filtered by pre-determined category
- category filter doesn’t work in WPML
- How do you categorize pages?
- Order of subcategories
- I cannot add more Categories to my menu
- “Categories” for six authors [closed]
- Filtering *out* a taxonomy from the admin post list
- category image taxonomy
- Categories overview that links to page displaying posts
- Category control subcategories
- Trying to add cat_ID to array for showing an image for specific Category
- Hidde certain category from post meta
- How to add a post without assigning to a category?
- List all posts in a category with query_post() function
- How to change amount of categories listed on dashboard?
- Remove “Browsed by Category” from Category Page
- How to display parents category and child category separately for a specific post?
- Display random categories
- Get a count of how many times a term or a category is used in posts
- Exclude a category name using cat name
- Get custom title if category
- Post by category+author not working!
- Custom template for sub-sub-categories
- display specific category on page
- Simple way to style posts of a single category differently in the loop and in single
- show WordPress categories with different Structure
- How to remove the tilte “category:category name”?
- why category__and and category__in wont work togather?
- PHP dynamical conditional post display
- wp_dropdown_categories initial value
- Advanced permalinks structure
- Subcategory Page URL to Display Only Posts from that Subcategory?
- How can I display image child category in parent
- Limit categories to hierarchal depth of 2
- Custom Taxonomy Isotope Grid – Filter Buttons Not Working
- Shop Category Pages missing s
- ADD DYNAMIC attribute for category to accordion
- Unable to add multiple categories to a post in WordPress
- How to display custom fields as table in Woocommerce
- make color of headline depend on category?
- How can I exclude a particular category from my WordPress Page 1 and Page 2?
- Menu with category 2 category combined
- Some subcategories not working on custom portfolio sort
- Link For Portfolio Categories
- Displaying Category in sidebar post widget but not in the loop on home
- Create duplicate category page with content variations
- Media Categories as Classes on WordPress Gallery Shortcode
- Category names dependent on each other?
- Category Template for Custom Post Type
- Loop Through Categories in Custom Field
- Backend – Categories and Menus conflicts
- get categories the post was in and just been removed from
- Loop through posts of CatA and store value of CatB in separate array
- Highlight posts that belong to current sub category
- How to add an empty entry to masonry?
- How to enable admins/editors to set a featured image for specific category?
- Problem with single posts not showing correct category sidebar
- Multiple Categories under one URL, where ‘Front Page’ is used already
- finding out the top 5 source ( source is a custom taxonomy ), in a given category
- How to display many photo albums related to category
- Having Trouble With get_category_by_slug In a Custom Function
- WordPress category gives 404 after moving to a different domain
- Create custom Perma link
- How to load/include category templates based on conditionals?
- Why does WordPress append a bullet to my category tag?
- how to implement next/prev within category archive?
- Add product category to post_class