Include HTML tags in custom fields

2019-08-15 01:42发布

问题:

I have a "currently reading" custom field in my WordPress blog post, and I want to output it wrapped in an HTML tag.

What I tried was this hack:

echo "<h1>" . $mycustomfieldcontent . "</h1>";

What the client prefers to do is to be able to set the HTML in the actual custom field.

What would be the proper way to do that?

回答1:

You're close. Pretty much the same as your previous question, see the screenshots:

Add your Custom Field with HTML in it.

Then display it with this:

<?php echo get_post_meta($post->ID, 'Your Meta Key', true); ?>

And the output should be: