This is an interesting topic. A WordPress/WooCommerce client could not add CSS via the usual way. In fact, Gravity Forms plugin (and in particular the “directory” extension), stores entries in the database BUT the directory page and the entries filtered list have the same classes, ids, and cannot be “targeted” with CSS.
Long story short, and Gravity Form or not Gravity Form, here’s the snippet you can use to add CSS to any WordPress page as long as you know its URL.

PHP Snippet: Apply CSS to a WordPress URL That Contains “abc”
/**
* @snippet Apply CSS if URL contains "abc" - WordPress
* @how-to businessbloomer.com/woocommerce-customization
* @author Rodolfo Melogli, Business Bloomer
* @compatible WooCommerce 8
* @community https://businessbloomer.com/club/
*/
add_action( 'init', 'bbloomer_apply_css_if_url_contains_string' );
function bbloomer_apply_css_if_url_contains_string() {
$url = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
if ( false !== strpos( $url, 'abc' ) ) {
echo '<style>.entry-title { color: red }</style>';
}
}
Hi! I should add the domain name to “SERVER NAME” and the path to “SERVER URI”??
Sorry for the confusion. The only thing you need to change is the “abc” search string, so if your URL is example.com/whatever you need to replace “abc” with “whatever“, and then write the CSS that you want to apply. That’s it!
NIIIIIIce thanks man!
You’re welcome!
Boom!!!! You are the man!
Thank you so much. I had a Javascript instead if this amazing function.
I just added this to load it in the head.
Thanks
Cool!
A very interesting thing happened when I applied the code. I used it for the WooCommerce My Account sub-page “orders” just to change an Elementor element I put above the my account shortcode. It broke the WooCommerce orders table, but only on mobile Safari and mobile Chrome and only the “display: block” attribute did not work anymore. When I changed the font of the table the CSS showed, but the “display” attribute is somehow broken. When I looked at it in Chromes inspect window with mobile view the table was normal. Very odd behaviour. On other pages with tables everything works fine when I use this code. Do you maybe know why the “display” attribute won’t work on the WooCommerce order table because of this code?
It depends on many things, and first of all on the CSS you applied. Want to share it here maybe?
Sure. I applied CSS to a row above the orders content from Elementor (which I made to as a navigation through the My Account part), to change the background-color and color of the “buttons” when the specific URL is activated. (you can see it here what happens, if the php code is applied: https://www.magentacloud.de/lnk/TwCFjgXz#file)
I applied this code:
This did not work for me – it put the resulting style at the very top of the html output – before the
Where did you place your CSS?
Hi! I used this snippet for changing CSS on specific pages where i need. It works perfect BUT:
Can I ask if using it multiple times in a short period gets the Imunify360 to block the ip?
Because that does happen, it changes the CSS of said page and nothing brakes, so before I freak out again I just want to make sure it’s just a safety measure and that I shouldnt worry? Or should I proceed in another way?
Hi Vanessa, no it shouldn’t
Hi, just wanted to let you know that I used something similar ages ago and wanted to use that code again and I was having a blank/couldn’t remenber the exact coding I did, cause I went withouth coding for years, bla bla bla.
TL;DR.
Ur example here is exactly what I used to do and I want to let other users know that it works like a charm.
Fantastic 🙂
Excellent PHP snippet, i changed “strpos” by “strripos” to apply it to last segment of an url
and it’s working!
Thank you
Nice 🙂
Thank you so much. This is such a big help. You are awesome!!!
Excellent 🙂
Thank you its work’s great !!
🙂
hello sir,
What if i want to call class or id of particular division on that page?
Chandan, thanks for your comment! I have no idea I’m afraid, I will need a URL and more information 🙂 Thanks!
thank you, this solved a huge problem for me
Awesome, thanks Todd!