0
votes

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!

2
I I don't know why... but now I found <?php echo get_post_meta($post->ID, "my_field", true);?> works.Tim Yao

2 Answers

1
votes

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

0
votes

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