Title: Get Post&#039;s Custom field values with wp_query()
Last modified: August 21, 2016

---

# Get Post's Custom field values with wp_query()

 *  Resolved [yonniq](https://wordpress.org/support/users/yonniq/)
 * (@yonniq)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/get-posts-custom-field-values-with-wp_query/)
 * 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
 * [https://wordpress.org/plugins/wck-custom-fields-and-custom-post-types-creator/](https://wordpress.org/plugins/wck-custom-fields-and-custom-post-types-creator/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [Cristian Antohe](https://wordpress.org/support/users/sareiodata/)
 * (@sareiodata)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/get-posts-custom-field-values-with-wp_query/#post-5119872)
 * It should work. You can have a look at the documentation, [http://www.cozmoslabs.com/docs/wordpress-creation-kit-documentation/#Custom_Fields_Creator](http://www.cozmoslabs.com/docs/wordpress-creation-kit-documentation/#Custom_Fields_Creator)
   but the code seems ok.
 * You might want to try to do
 *     ```
       $social = get_post_meta( get_the_ID(), 'social', true );
       echo '<pre>';
       var_dump( $social );
       echo '</pre>';
       ```
   
 * and see if there’s anything in the social variable.

Viewing 1 replies (of 1 total)

The topic ‘Get Post's Custom field values with wp_query()’ is closed to new replies.

 * ![](https://ps.w.org/wck-custom-fields-and-custom-post-types-creator/assets/icon-
   256x256.png?rev=2257602)
 * [Custom Post Types and Custom Fields creator - WCK](https://wordpress.org/plugins/wck-custom-fields-and-custom-post-types-creator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wck-custom-fields-and-custom-post-types-creator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wck-custom-fields-and-custom-post-types-creator/)
 * [Active Topics](https://wordpress.org/support/plugin/wck-custom-fields-and-custom-post-types-creator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wck-custom-fields-and-custom-post-types-creator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wck-custom-fields-and-custom-post-types-creator/reviews/)

## Tags

 * [custom fields](https://wordpress.org/support/topic-tag/custom-fields/)
 * [WCK](https://wordpress.org/support/topic-tag/wck/)
 * [wp_query](https://wordpress.org/support/topic-tag/wp_query/)

 * 1 reply
 * 2 participants
 * Last reply from: [Cristian Antohe](https://wordpress.org/support/users/sareiodata/)
 * Last activity: [11 years, 10 months ago](https://wordpress.org/support/topic/get-posts-custom-field-values-with-wp_query/#post-5119872)
 * Status: resolved