jankowalski 3 Report post Posted May 14, 2012 As @kastelic suggested in one of his posts, i am using this code to display custom post type on my homepage add_filter( 'pre_get_posts', 'my_get_posts' ); function my_get_posts( $query ) { if ( is_page( 'not-here' ) ) return $query; if ( $query->is_home || is_feed && !isset($query->query_vars['post_type'])) $query->set( 'post_type', array( 'post', 'book', 'games' ) ); return $query; } Can i assign a template for this loop? At the moment template depends on the first post on the list, if it is book => book template, if game post is first on the list thangames template is loaded. how to set default template for query? Share this post Link to post Share on other sites
Danny+ 1,327 Report post Posted May 14, 2012 Hi Jan, Could you not create a new template to be used only for your custom post types and then create the above code you added into a custom section and drag and drop this custom section on the newly created template for CPT ? Please search our forums, before posting! Share this post Link to post Share on other sites
jankowalski 3 Report post Posted May 14, 2012 I have template for each custom post, i guess it was created automaticly while creating custom post type. what do you mean by [quote]Could you not create a new template to be used only for your custom post types[/quote]Sorry but i didn t get it. Share this post Link to post Share on other sites
jankowalski 3 Report post Posted May 14, 2012 Ok, i have created new section with diferent loop for each custom post type and assigned to diferent template. it works now. still need to figure out how to add more custom post types to this loop: [code]class PageLinesPostLoopOne extends PageLinesSection { function section_template() { query_posts( array( 'post_type' => 'video' 'paged' => get_query_var('paged')) ); //Included in theme root for easy editing. $theposts = new PageLinesPosts(); $theposts->load_loop(); } }[/code] i tried change the line query_posts( array( 'post_type' => 'video', 'paged' => get_query_var('paged')) ); to query_posts( array( 'post_type' => 'video', 'books', 'paged' => get_query_var('paged')) ); but books are not showing up, can you help? Share this post Link to post Share on other sites
catrina 103 Report post Posted May 15, 2012 Where is books not showing up? As a post type in the post editor? Try taking the comma out between the video and paged post types. Please read the docs before posting. Please do not private message me unless I ask you to. Designer | Catrina Dulay Founder | Catrina and Mouse Share this post Link to post Share on other sites
jankowalski 3 Report post Posted May 16, 2012 no it is not showing in the post loop on the client side. taking the coma out cause [code]Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' [/code] just somebody please tell me how to construct array so i can add more custom post types to thi line. also, pagination is broken... thanks Share this post Link to post Share on other sites
Simon 248 Report post Posted May 16, 2012 You need to use an array. [code] query_posts( array( 'post_type' => array( 'video', 'books' ), 'paged' => get_query_var( 'paged' ) ) ); [/code] Share this post Link to post Share on other sites
jankowalski 3 Report post Posted May 16, 2012 great, it works, however pagination was still broken, so the final version would be: [code]query_posts( array( 'post_type' => array( 'video', 'books' ), 'paged' => get_query_var( 'page' ) ) );[/code] thanks! Share this post Link to post Share on other sites