I am currently working on a WordPress, with WooCommerce functionality.

I want to create 2 Conditions, as to echo a piece of text on one product page, another piece of text on another product page and then another piece of text to echo on all over product pages. To achieve this, I have gone into the content-single-product file, and entered the following code:

<?php
    if (is_product('product-a-slug')) {
        echo 'Product A Specific Text';
    }

    elseif (is_product('product-b-slug')) {
        echo 'Product B Specific Text';
    }

    else {
        echo 'Other Product Text';
    }
?>

Unfortunately, the only text which is triggered is the ‘Product A Specific Text’. Also, this text appears across all of the Product Pages, thus not following my Conditional Logic. I have browsed both WordPress Codex and WooCommerce Documentation, though I cannot see what is wrong with the code.

Anyone able to see where I could be going through?

Read more here: Why is only the first line of my Conditional Logic tag being recognised?


Solution:

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: