-1

I have a custom field with name and value (case sensitive) as follows: style; rgb(240,180,41)

The code to retrieve this is included within the loop on my single.php file:

    <h2 style="
text-shadow: 2px 2px <?php get_post_meta(get_the_ID(), 'style', true); ?>; 
-webkit-text-stroke: 1px <?php get_post_meta(get_the_ID(), 'style', true); ?>;">

The h2 on the page has a 2px 2px shadow and a 1px outline, but it is not pulling through the custom color as specificied in the 'value' field of the custom field.

Any help much appreciated!

Chris L
  • 109
  • 8

1 Answers1

1

get_post_meta will only return the value, you should put echo in it when displaying the value;

something like;

<?php $color =  get_post_meta(get_the_ID(), 'style', true); ?>
<h2 style="
    text-shadow: 2px 2px <?php echo $color; ?>; 
    -webkit-text-stroke: 1px <?php echo $color; ?>;
">
silver
  • 4,433
  • 1
  • 18
  • 30