Hi
Firstly great themes! Love them all.
I have a custom post type I have created and want to display them in with the normal posts. Apparently this can be done and there are many variations that tell us to edit the functions.php file or even the index.php file. I have tried both files, each with variations of the code supplied by blogs and forums (some examples are below).
So the questions is, where exactly in Travelify can I put some code to mix the custom post types in with the normal post types, and indeed which code (if any) below is correct?
–My custom post type is named ‘recipesposttype’
Thanks!!
add_filter( 'pre_get_posts', 'my_get_posts' );
function my_get_posts( $query ) {
if ( is_home() && $query->is_main_query() )
$query->set( 'post_type', array( 'post', 'page', 'recipesposttype' ) );
return $query;
}
add_filter( 'pre_get_posts', 'my_get_posts' );
function my_get_posts( $query ) {
if ( is_home() && false == $query->query_vars['suppress_filters'] )
$query->set( 'post_type', array(
'post', 'page', 'recipesposttype' ) );
return $query;
}
<?php
if( is_home() ){
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts( array('post_type'=>array(
'post','page','album','movie','recipesposttype'
),'paged'=>$paged ) );
}
?>
// Show posts of 'post', 'book' ,'movie' ,'page' 'joke', 'event' post types on home page
add_action( 'pre_get_posts', 'add_custom_post_types_to_home_page' );
function add_custom_post_types_to_home_page( $query ) {
if ( is_home() && $query->is_main_query() )
$query->set( 'post_type', array( 'post', 'recipesposttype' ) );
return $query;
}