Query for custom post type. Use the pre_get_posts
filter and just set the portfolio
post type for the main query. Use Conditional Tags to determine where you want to have this filter.
Quick Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <?php defined( 'ABSPATH' ) OR exit; /* Plugin Name: (#6417) "Portfolio" post type in query */ add_filter( 'pre_get_posts', 'wpse_6417_portfolio_posts' ); function wpse_6417_portfolio_posts( $query ) { if ( ! $query->is_main_query() // Here we can check for all Conditional Tags OR ! $query->is_archive() // For e.g.: Every archive will feature both post types ) return $query; $query->set( 'post_type', array( 'post', 'portfolio' ) ); return $query; } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.