Special Bundle Offer! All-in-one Pack (Script + Android + iOS + Installation) Buy Now

How to add css code for a specific page using PHP in wordpress?

By Blog

We are here to learn something new right !! By the way, a WordPress/WooCommerce shopper couldn’t add CSS via the standard manner. In fact, Gravity Forms plugin (and above all the “directory” extension), stores entries within the info however the directory page and therefore the entries filtered list have a similar category, ids, and can’t be “targeted” with CSS. Long story short, and Gravity type or not Gravity type, here’s the piece you’ll be able to use to feature CSS to any WordPress page as long as you recognize its URL.

To apply CSS programmatically to a page URL that contains a string such as “contact” for example.,

Add this code into functions.php.,


add_action( ‘init’, ‘do_stuff_with_url’ );

function do_stuff_with_url() {

$url = ‘http://’ . $_SERVER[‘SERVER_NAME’] . $_SERVER[‘REQUEST_URI’];

if (false !== strpos($url,’contact’)) {
echo ‘<style type="text/css">
.entry-title {color: red !important}


Finally you can the check the page and the changes will be there.

Tagged under: