Need CSS for each page using custom fields
-
I want each page to have a different color border-bottom under the title. At first I made an external stylesheet for each page but this seemed like overkill. I then embedded an inline style for page in the page editor but heard this is not very clean either.
I found a solution at https://www.wprecipes.com/how-to-embed-css-in-your-posts-with-a-custom-field which said place this code in header.php between head tags:<?php if (is_single()) { $css = get_post_meta($post->ID, 'css', true); if (!empty($css)) { ?> <style type="text/css"> <?php echo $css; ?> </style> <?php } } ?>
and I wrote a custom field called css with a value of:
#content_container h2{ border-bottom: solid 3px #ff5523; }
but this didn’t work.
Anyone know what I’m doing wrong and are custom fields the way to go?
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Need CSS for each page using custom fields’ is closed to new replies.