I'm not an educated programmer, but usually i can put existing code together so it works the way i want it to. But this time i'm lost, i feel like i've tried everything.

I'm trying to only show a template part if the product is part of a specific term. This is one of the numerous code snippets i've tried.

I hope it makes sense to what i'm trying if not i'll answer any questions :)

 $taxonomy = taxonomy_exists( 'produkttype' );
 if ( $term = 'pude' && $term = 'senge' ) {
      echo get_template_part( 'partials/sections/section', 'trustpilot' );
  • Use the get_the_terms() function instead of taxonomy_exists(). In your code you only check if the term has been defined, not if it is assigned/associated to the post. Look at accepted answer in this question.
    – nmr
    Commented Dec 17, 2019 at 10:18
  • Thank you for your answer. I had tried the get_the_terms, just not in the correct way. I now know what the taxonomy_exists () does, thank you :) Commented Dec 17, 2019 at 11:02

1 Answer 1


Try this

if( has_term('pude', 'produkttype') || has_term('senge', 'produkttype')) {

   get_template_part( 'partials/sections/section', 'trustpilot' );

  • This seems to work, thank you very much for your fast reply! Commented Dec 17, 2019 at 11:00
  • @webmastertouche great, consider marking it as right answer.
    – Yatix
    Commented Dec 17, 2019 at 11:01
  • Yes of course, it's done :) Commented Dec 17, 2019 at 11:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.