Include HTML tags in custom fields

2019-08-15 01:41发布

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条回答
萌系小妹纸
2楼-- · 2019-08-15 02:29

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

Add your Custom Field with HTML in it. enter image description here

Then display it with this:

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

And the output should be:

enter image description here

查看更多
登录 后发表回答