Custom CSS Stylesheet for Individual Posts
Posted by Susan Tyson on 08 June 2016 06:00 PM

There are sites that use custom stylesheet for individual posts. Do you want to know how you can do it also? It is very simple. This is accomplished by the use of Custom Fields.

First you will need to open your header.php and insert this code somewhere in between <head></head> codes.

1 <?php if (is_single()) {
2 $customstyle = get_post_meta($post->ID, 'customstyle', true);
3 if (!empty($customstyle)) { ?>
4 <style type="text/css">
5 <?php echo $customstyle; ?>
6 <style>
7 <?php }
8 } ?>

Once you have done that you can add a custom field in each post with the name customstyle and add the css codes in there.

For example if you want the a certain image to have border you can add:

1 #coolimageclass{border: 5px solid #ccc;}

Use the format above and you now have custom CSS for your single posts.

(0 vote(s))
Not helpful

Comments (8)
13 July 2016 08:17 PM
Who was their leader (king )? What cuerrncy did they use then? How come they dont even have stories of how great their culture was ?
13 July 2016 09:10 PM
Have you given any kind of thought at all with trtaslaning your current web page in to Chinese? I know a couple of translaters here which would certainly help you do it for no cost if you want to make contact with me personally.
17 July 2016 01:39 PM
Shoot, so that's that one supeosps. [url=]utdpak[/url] [link=]fynzbu[/link]
17 July 2016 01:39 PM
What a pleasure to find someone who idenfities the issues so clearly [url=]jrbgpb[/url] [link=]lzwdgfjtvj[/link]
18 July 2016 08:23 PM
Lot of smarts in that <a href="">poigsnt!</a>
18 July 2016 08:23 PM
Learning a ton from these neat <a href="">arsiclet.</a>
19 July 2016 02:06 AM
Great article but it didn't have evrtiehyng-I didn't find the kitchen sink! [url=]aboxigmv[/url] [link=]hkfrmpmata[/link]
19 July 2016 02:06 AM
This poitsng knocked my socks off [url=]uihhzlwh[/url] [link=]iyeupw[/link]
Post a new comment
Full Name:
CAPTCHA Verification 
Please enter the text you see in the image into the textbox below (we use this to prevent automated submissions).