0

I'm using a Wordpress plugin called "easy content types" which provides a rich text editor to help you add HTML format textarea in to the custom field. I want to display the content in my template page.

Usually I use get_post_meta($post->ID, "my_field", true) to get a custom field meta value. But in this case, it does not work. Seems get nothing.

I can display the value use <php? the_meta(); ?> in my template. But I have no idea how to display this specific field use get_post_meta( ) or other Wordpress functions.

The "easy content types" plugin provides a method <php? ecpt_display_meta('meatbox');?> to get the value also. But it can only get the value of a group of fields, that's not what I want actually.

I've searched in google for answers, but can't find related questions. So hope some one can help me. Thanks!

1
  • I I don't know why... but now I found <?php echo get_post_meta($post->ID, "my_field", true);?> works. Commented Feb 16, 2012 at 23:16

2 Answers 2

2

If your custom field is a multiline text, you can echo that like this to be in HTML format:

<?php
$customfield_content=get_post_meta($post->ID, 'customfield-name',true);
$customfield_content = apply_filters( 'the_content', $customfield_content );
$customfield_content = str_replace( ']]>', ']]&gt;', $customfield_content );
echo $customfield_content;
?>

Or use the way described in this website

Sign up to request clarification or add additional context in comments.

Comments

0

how about..

<?php 
$myfield = get_post_meta($post->ID, "my_field", $single = true);
echo $myfield;
?>

just have a check and make sure the custom field your trying to access is using the same name.

Marty

2 Comments

Thanks. I don't know why... but now I found <?php echo get_post_meta($post->ID, "my_field", true);?> also works.
That's because it does exactly the same thing, maybe?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.