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 Page URL That Contains “string”

/**
 * @snippet       Apply CSS if URL contains string - WordPress
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 3.5.7
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

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, 'string' ) ) {
    echo '<style type="text/css">
         .entry-title { color: red }
         </style>';
} 
 
}
Share:

Leave a Reply