I am currently working on a WordPress website, where I am trying to place a few Template Files into the functions.php file. The Template Files need to be placed within a series of Conditional Tags as follows:

function template_selections(){

    if ( is_single( 'product_url_slug' ) ) {
        get_template_part( 'template-folder/template-file-name' );
    } 
    elseif ( is_single( 'product_url_slug' ) ) {
        get_template_part( 'template-folder/template-file-name' );
    }
    elseif ( is_single( 'product_url_slug' ) ) {
        get_template_part( 'template-folder/template-file-name' );
    }
}

add_action ('woocommerce_before_add_to_cart_button', 'template_selections');

For some reason, the Templates are not being called. As to ensure the Template Files were correctly uploaded to the server, I entered and the Template was called. So there is obviously something wrong with the Conditional Tags.

I have browsed WordPress Codex but cannot seem to find a resolution.

Is anyone able to see where I am going wrong with the above code?

Thanks, in advance.

Read more here: How can I successfully call my Template Files, within Conditional Tags?


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: