Advertisement
miriamdepaula

WordPress: Adding all post types in archive query

Aug 25th, 2013
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.42 KB | None | 0 0
  1. /* Add this function in the functions.php file */
  2.  
  3. function wpmidia_custom_post_types_archives($query) {
  4.         $post_types = array('post','custom1','custom2','custom3');
  5.         if ( ! is_archive() && ! in_array( get_post_type(), $post_types ) )
  6.                 return $query;
  7.  
  8.         $query->set( 'post_type', $post_types );
  9.  
  10.         return $query;
  11. }
  12. add_filter('pre_get_posts', 'wpmidia_custom_post_types_archives');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement