I am currently working on a WordPress website, where I am having problems with inserting Conditional Tags into the content-single-product file.

The website currently has 3 Product Categories. For the purpose of this question, lets call them:

  • Product Category A
  • Product Category B
    • Product A
    • Product B
    • Product C

I do not want any of the Products, within Product A to call my Template File(s). As for Products in Products in Product Category B, I want them to call the Template Category B Single Product Default by default. Then within this Category, I want Product A to call the Template file ‘Product A Modification’ with Product B calling the Template file ‘Product B Modification’. To achieve this, I have inserted the following code into the content-single-product file:

    if ( is_category( 'Product Category B' ) ){
        get_template_part( 'modifications/product-category-b-default' );
    elseif ( is_single( 'product_a_url_slug' ) ) {
    get_template_part( 'modifications/product-a-modification' );
    elseif ( is_single( 'product_b_url_slug' ) ) {
    get_template_part( 'modifications/product-b-modifications' );
    elseif ( is_single( 'product_c_url_slug' ) ) {
    get_template_part( 'modifications/product-c-modifications' );  

Is anyone able to see where I have gone wrong above, as the above code, prevents the Single Product page from fully loading.

Read more here: Why do my Conditional Tags fail to load the body of my website?


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: