Use custom field to define post title color on a per post basis
-
I would like to setup a custom field to define the color of the post title on a per post basis. I have already setup a custom field to define the background color on a per post basis by adding this line:
style="background-color:<?php echo(get_post_meta($post->ID, 'custom-bgcolor', true));?>;">
Directly after this line in my content.php
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>
I know next to nothing about this and everything I have done is the result of Google searches and trial and error.
I did try adding the following lines to my content.php and it worked:
<header id="entry-title a<?php the_ID(); ?>" <?php post_class(); ?> style="color:<?php echo(get_post_meta($post->ID, 'custom-title', true));?>;">
<header id="entry-title a:hover<?php the_ID(); ?>" <?php post_class(); ?> style="color:<?php echo(get_post_meta($post->ID, 'custom-title-hover', true));?>;">
But it also added extra padding to the top and bottom of all my posts. I assume this was the result of using header id.
I’m using a child theme and my site is here
For reference, here is a pastebin of my content.php as is with only the custom background.
And here is a pastebin of the content.php that worked but added extra padding.
Can anyone help me out or point me in the right direction?
Thanks.
- The topic ‘Use custom field to define post title color on a per post basis’ is closed to new replies.