change background for specific page and category in wordpress

change background for specific page and category in wordpress

WordPress tutorial, We will show how to change background for specific page and category in wordpress theme. achieve using conditional tags.

change background for specific page and category in wordpress

Many times clients demands for different background color or different images as a background. We can very easily achieve this using wordpress conditional tags.

change background for specific page and category in wordpress
change background for specific page and category in wordpress

You can use following code in your page.php or category.php file which is present in wordpress theme. If you want to change the background for specific page then open page.php file from theme folder.


<body <?php if(is_page('contact us'))&nbsp; echo 'class="contact_us"';?>>

Use following css code in your style.css file


.contact_us{

.background-color:#ccc;

}

.php_category{

.background-color:#181818;

}

If you want to use different background for your category then use following code.



<body <?php if(is_category('php''))&nbsp; echo  'class="php_category"';?>>

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

One thought on “change background for specific page and category in wordpress”

Leave a Reply

Your email address will not be published.