I have a custom post type which is called "scholarship". Archive page for custom post type is disabled. I am using category (Scholarships) which also has subcategories. I have used following code to include CPT in loop.
function add_custom_post_type_to_query( $query ) {
if ( $query->is_home() || is_category() && $query->is_main_query() ) {
$query->set( 'post_type', array('post', 'scholarship') );
} } add_action( 'pre_get_posts', 'add_custom_post_type_to_query' );
When i use this code, 5 CPT are showing up. Total are 8. CPT in Scholarships-subcategories are not showing up and after putting this code my all menus disappear. I have main menu plus one custom menu in footer. If any one could help please.
get_posts
the default pagination is set to 5 posts per page codex.wordpress.org/Function_Reference/get_postsif
statement evaluates to true for any query whereis_home
is true, which includes menus and secondary queries on the page. also, a helpful debugging method is to inspect the contents of$wp_query
in your template, you will see how the query vars are set and the SQL query being sent to the database.