Advertisement
Guest User

Untitled

a guest
Jun 19th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. function my_cptui_add_post_types_to_archives( $query ) {
  2. // We do not want unintended consequences.
  3. if ( is_admin() || ! $query->is_main_query() ) {
  4. return;
  5. }
  6.  
  7. if ( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
  8. $cptui_post_types = cptui_get_post_type_slugs();
  9.  
  10. $query->set(
  11. 'post_type',
  12. array_merge(
  13. array( 'post' ),
  14. $cptui_post_types
  15. )
  16. );
  17. }
  18. }
  19. add_filter( 'pre_get_posts', 'my_cptui_add_post_types_to_archives' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement