Get Post's Custom field values with wp_query()
-
Hi I have a similar problem. I have a
metabox:Social Links
metabox arguments with meta name: socialI have two fields facebook,twitter linked to posts. I can see them and their default values ‘#’ when I create a post. So I assume the set up part works. Now I write a function
$args = array( 'post_type' => 'post', 'category_name' => 'directors', 'orderby'=> 'id', 'posts_per_page' => 1, 'order' => 'asc' ); $post_query = new WP_Query($args); if($post_query->have_posts() ) { while($post_query->have_posts() ) : $post_query->the_post(); $social = get_post_meta( get_the_ID(), 'social', true ); foreach ($social as $link) { echo $link['facebook'] . '<br/>'; echo $link['twitter'] . '<br/>'; } endwhile; }
The function echos nothing when called. I am not sure where I went wrong
https://www.ads-software.com/plugins/wck-custom-fields-and-custom-post-types-creator/
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Get Post's Custom field values with wp_query()’ is closed to new replies.