Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. $red_templ = ['strawberries', 'tomatoes', 'raspberries']; // term slugs
  2. $green_templ = ['watermelons', 'apples', 'kiwi']; // term slugs
  3. $template = 'fruits';
  4.  
  5. $obj = get_queried_object();
  6. if ( $obj instanceof WP_Term ){
  7. if ( in_array($obj->slug, $red_templ) )
  8. $template = 'redfruits';
  9. else if ( in_array($obj->slug, $green_templ) )
  10. $template = 'greenfruits';
  11. }
  12. while ( have_posts() ) : the_post();
  13.  
  14. get_template_part( 'content', $template );
  15.  
  16. endwhile;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement