Hi I have a similar problem. I have a
metabox:Social Links
metabox arguments with meta name: social
I 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