You need something like this in you functions.php file, I’m using the action Pieter suggested.
function add_custom_post_type_to_query( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( 'post_type', array('post', 'article') );
}
}
add_action( 'pre_get_posts', 'add_custom_post_type_to_query' );
Related Posts:
- Pagination not working with custom loop
- Display all posts starting with given letter?
- wp_pagenavi() with custom wp_query()?
- Retrieving 3 latest post from each of 5 different custom post types
- How to query custom posts using a dynamic category
- WordPress “Loop” with large set of results
- Newer/Older posts links display same posts on every page
- How to solve suspected memory issue in custom WordPress loop?
- List events by month
- WP_Query on custom post type not displaying, multiple loops & get_template_part
- Conditional two level dropdown filter for custom post type
- Show all custom post type posts sorted by custom taxonomy then by another custom taxonomy
- Group search results by post type, but hide post types with no results
- How to create posts (not post template) to be displayed on projects page?
- Custom Post Loop in Archive returns same the_permalink
- WP_Query post at custom position
- Pagination with custom post types results in 404 issues
- Problems excluding a custom post-type from the loop
- How do you output custom code between posts in the loop?
- How do I Use Nested Loops of Custom Post Types for MultiSite Blogs using WP_Query()
- Impossible to get Attachments Outside WordPress?
- List posts AND custom post type by category
- Help Structuring Query for Archive Pages
- Custom Post Type not visible on category page
- wp_query to find posts by year and month
- Loop of custom post type names
- get_template_part for each level of taxonomy term
- Query custom post type in the loop
- Creating Multiple Loops in Genesis, One Post then 20, each with custom fields
- Loop through Custom Post Type, and then show children within each iteration
- Very Slow Page – How to Optimize # of Queries?
- WordPress Genesis custom taxonomy archive shows 3 repeats of each post
- How do i calculate the total of values of custom fields in custom post types?
- Custom post type not displaying content from single-{custom post type} page
- Display all taxonomy terms, add class if term applies to current post
- Best way to style first post differently?
- A to Z List of Custom Post Type in three columns
- WP Query with categories only shows one post and ignores the category
- Post ID randomly printing on page
- Posts per row on archive page (custom post type)
- How do I know the ‘meta_key’ for ordering my custom post type
- WordPress Loop if/else
- Sort posts in loop by the WooCommerce Membership of the author
- How to include custom post type posts on a page?
- 4 column-loop ordered alphabetically with entries grouped (and labeled) by their first letter
- Custon Content within WordPress Loop
- Custom post type showing same Post on all Pages
- Create Array from custom post type to display a slider
- get parent content inside child posts
- Get data from PHP to JavaScript to set position of each post on front page
- display posts of custom post type with custom taxonomy
- assign different templates to custom post type with homepage loop
- Custom Post Type and Taxonomy Loop Output Is Wrong
- foreach loop inside the loop creating duplicates in output
- How to fetch posts that are stored in the different table than (default) wp_posts?
- Cant’ Display Custom Post Type Title Base on Tax Terms
- CPT archive page – show one post from each taxonomy term
- How do i display post from a taxonomy term?
- Custom loop request based on custom field
- Use Author Ids or Names to echo different output inside loop
- If/Else child list for Custom Post Type single template within loop?
- Insert a Custom Post type into my Loop
- Custom Post Types Not Showing Up In query_posts Result
- Do I need a loop to display an object that attached to posts?
- “Order” doesn’t work in custom loop?
- CPT loop doesn’t seem to account for post date?
- How to display list of custom post taxonomy terms and their posts (if any)?
- Shortcode with loop stacks output
- Show custom post type event if current day using ACF
- How to create an IF statement in the Main Loop for Custom Post Types
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- How to output and alert message when updating a post
- Wrapping an unknown amount of posts inside separate HTML Containers during WP_Query loop
- sorting in wp query based on custom field value
- Custom post Query and WordPress Post Query Clash
- Add active class to foundation 6 tabs while looping categories
- Custom post type loop without children
- How to display user-defined / custom post in wordpress?
- WordPress loop add heading before first of type
- Only show current category post
- How to make a shortcode for my WP_Query Loop? [duplicate]
- Looping through custom taxonomy in one template
- get_post_meta for Custom Post Type ( CPT )
- All custom posts are not showing up
- How to keep a CPT stick to specific position?
- Is it possible to add query parameters on the archive page?
- Custom post type archive pagination with HTML5Blank theme?
- How to create content automatically when a post is published?
- WordPress loop for multiple custom post types
- Pagination not working with custom loop
- Fallback if statement based on the number filtered from it
- Create custom post order (with custom post type meta)
- Pagination not working with custom loop
- Pagination not working with custom loop
- Noob Loop Question
- Custom Post Types and 404 Pages
- Catergory args causing loop not to show
- show custom post’s post in two different divs [duplicate]
- Limit wordpress posts loop to continue onto another page
- Complex Custom Loop with Includes