Wordpress - Multiple Post Types in Loop


/ Published in: PHP
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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

You need to login to post a comment.