Title: How to Set Conditional Statement
Last modified: November 22, 2023

---

# How to Set Conditional Statement

 *  Resolved [danieloe918](https://wordpress.org/support/users/danieloe918/)
 * (@danieloe918)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/how-to-set-conditional-statement/)
 * Hello I’m looking to set a conditional statement on a javascript file so that
   this style:
   **<style>.term-44 header.woocommerce-products-header:not(.active):
   after {content: “More..”;color: #000000;cursor: pointer;}</style>Only appears
   on a specific page with H1 = “Porcelain Tiles”I wrote a javascript file:<script
   >
 * document.addEventListener(‘DOMContentLoaded’, function() { 
   // Check if the page
   contains an h1 element with the title “porcelain tiles” var pageTitle = document.
   querySelector(‘h1’); if (pageTitle && pageTitle.textContent.trim().toLowerCase()
   === ‘porcelain tiles’) { // Create a style element and append it to the head 
   of the document var style = document.createElement(‘style’);style.textContent
   = `.term-44 header.woocommerce-productsheader:not(.active):after { ``content:"
   More.."; ``color: #000000; ``cursor: pointer; } `; document.head.appendChild(
   style); } });</script>In the custom code for the theme doesn’t work.Note: I’m
   not using Page ID since when I press the sidebar the styling persist not applicable
   to other pages that are connected to the sidebar.Can you guys help edit the code?
   or make a better one?I’m using an elementor custom code connected to the woocommerce
   collection page list
    -  This topic was modified 2 years, 6 months ago by [danieloe918](https://wordpress.org/support/users/danieloe918/).

Viewing 1 replies (of 1 total)

 *  [xue28 (woo-hc)](https://wordpress.org/support/users/xue28/)
 * (@xue28)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/how-to-set-conditional-statement/#post-17226348)
 * Hi [@danieloe918](https://wordpress.org/support/users/danieloe918/)
 * Thanks for reaching out!
 * This is a bit of a complicated topic that would need some customization to address.
   Unfortunately, [custom coding](https://woocommerce.com/support-policy/) is not
   something we can assist with directly. However, I’ll keep this thread open for
   a bit to see if anyone from the community can lend a hand.
 * If you have any other questions related to development or custom coding, don’t
   hesitate to reach out to some of the great resources we have available for support.
   The WooCommerce community is filled with talented open-source developers, and
   many of them are active on the channels listed below:
    - [WooCommerce Developer Resources Portal](https://developer.woocommerce.com/)
    - [WooCommerce Advanced Facebook group](https://www.facebook.com/groups/advanced.woocommerce/)
    - [WooCommerce Developer Slack Channel](https://woocommerce.com/community-slack/)
    - Hire a [WooCommerce Expert](https://woocommerce.com/experts/)
 * Hope this helps!

Viewing 1 replies (of 1 total)

The topic ‘How to Set Conditional Statement’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

## Tags

 * [css](https://wordpress.org/support/topic-tag/css/)
 * [javascript](https://wordpress.org/support/topic-tag/javascript/)

 * 1 reply
 * 2 participants
 * Last reply from: [xue28 (woo-hc)](https://wordpress.org/support/users/xue28/)
 * Last activity: [2 years, 6 months ago](https://wordpress.org/support/topic/how-to-set-conditional-statement/#post-17226348)
 * Status: resolved