Custom Field Display Issue
-
I am using the following code to display Meta Keywords and Meta Decriptions using custom fields.
<?php if($meta_keywords= get_post_meta(get_the_ID(), 'meta_keywords', true)) echo '<meta name="keywords" content="' ; echo $meta_keywords ; echo '" />' ; ?>
<?php if($meta_description= get_post_meta(get_the_ID(), 'meta_description', true)) echo '<meta name="description" content="' ; echo $meta_description ; echo '" />' ; ?>
The code works perfectly as long as I populate the custom fields however if do not add the custom field to page each page ends up with the ” /> ” /> showing at the top of the page.
Would anyone be able to shed some light on what I am doing wrong.
Many thanks
James
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Custom Field Display Issue’ is closed to new replies.