Posted By

cpres on 08/02/11


Tagged

post wordpress types custom


Versions (?)

Wordpress - Multiple Post Types in Loop


 / Published in: PHP
 

add this to functions.php and you won't have to mess with the index page.

  1. add_filter( 'pre_get_posts', 'my_get_posts' );
  2.  
  3. function my_get_posts( $query ) {
  4.  
  5. if ( is_home() && false == $query->query_vars['suppress_filters'] )
  6. $query->set( 'post_type', array( 'post', 'page, 'albums' ) );
  7.  
  8. return $query;
  9. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: cpres on August 2, 2011

'albums' in this example is a custom post type.

It's intermediately easy to add custom post types through the functions.php but I've had better luck not causing issues with a Custom Post Type UI Plugin

You need to login to post a comment.