• Resolved Abdi Issak

    (@aissak)


    Hello Everyone,

    I am currently trying to write a if-statement based on my current template. In QueryMonitor it shows that my current template is the Woocommerce plugin’s ‘templates/single-product’. The issue is when I call get_page_template() in my child themes functions.php it returns ‘page.php’ as my current page template.

    My end goal is to write the following conditional for my product page.

    `if ( single-product ) { // enqueue scripts }

Viewing 1 replies (of 1 total)
  • Thread Starter Abdi Issak

    (@aissak)

    UPDATE:

    Thanks to this post on Stackoverflow, I decided to override the woocommerce/templates/single-product.php in my child theme and enqueue my scripts before the wp_header() call. Which is a working solution for targeting for my goal of enqueueing scripts by targeting the specific template file, allowing me to avoid the unnecessary if-statement. Does anyone know a better method if so I will be open to suggestions otherwise I will just mark this as resolved.

    • This reply was modified 2 years, 6 months ago by Abdi Issak.
Viewing 1 replies (of 1 total)
  • The topic ‘How would I target a specific Woocommerce template file in my Child Theme?’ is closed to new replies.