0

Can some one let me know How I can render the Custom Post Type Meta Fields (Meta-boxes). I have a Custom Post Type Called "News" and I successfully added a Metabox to my Custom Post Type called "News Info" which is suppose to store :
A TextField = News Resource

A Select option = News Type

A check box

enter image description here

I can retrieve the Custom post Type "News"content using a custom Loop as:

<?php
 $args = array( 'post_type' => 'news');
 $loop = new WP_Query( $args );
 while ( $loop->have_posts() ) : $loop->the_post();
    the_title();
    echo '<div class="content">';
    the_content();
    echo '</div>';
 endwhile;
?>

But I have no idea how to get the associated meta fields to "news" posts? trust me I Google this a lot but couldn't find any solution all of them just tried to render the Metabox on the admin page but no sample for presenting on the page! Can you please let me know how I can get access and render the data on the page using the wp-query loop?

Thanks

3
  • This page never came up when you were Googling? codex.wordpress.org/Custom_Fields
    – s_ha_dum
    Commented Nov 7, 2013 at 0:59
  • Hi, well I am lost here! are the Custom Fields same as Metaboxes? if so why are ...?
    – Behseini
    Commented Nov 7, 2013 at 1:17
  • No, they are not the same but you would normally save data from a custom meta box as post meta (custom fields). If that is not the case, or if you don't understand what that means, then you need to do a lot of work to clarify the question.
    – s_ha_dum
    Commented Nov 7, 2013 at 1:59

1 Answer 1

1

Use get_post_meta() function to get value of desired meta key.

You can get more details on this link: http://codex.wordpress.org/Function_Reference/get_post_meta

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.