Title: [Plugin: Simple Fields] Using within WP_Query loop
Last modified: August 20, 2016

---

# [Plugin: Simple Fields] Using within WP_Query loop

 *  [katmac_aus](https://wordpress.org/support/users/katmac_aus/)
 * (@katmac_aus)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/plugin-simple-fields-using-within-wp_query-loop/)
 * Hi. I am having trouble using this within the WP_Query. It’s working fine within
   the post loop but not when I try run a loop. Here is the scenario I am running:
 * I have a custom post type called videos and use the simple fields filename and
   category. When I run code the following in the single output it works as expected:
 * $filename = simple_fields_get_post_value($postID, array(1, 1), true);
    $category
   = simple_fields_get_post_value($postID, array(1, 2), true);
 * However after this post I would like to show a list of related videos. I have
   a WP_Query which works to get all my video post but when I try filtering by simple_fields
   values it gets no results. Here is the code I am using:
 *  <?php $loop = new WP_Query( array(
    ‘post_type’ => ‘rm_video’, ‘posts_per_page’
   => 5, ‘orderby’ => ‘title’, ‘meta_key’ => ‘_simple_fields_fieldGroupID_1_fieldID_2_numInSet_0’,‘
   meta_value’ => $category )); ?>
 * Any suggestions?
 * [http://wordpress.org/extend/plugins/simple-fields/](http://wordpress.org/extend/plugins/simple-fields/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Anonymous User
 * (@anonymized-2240233)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/plugin-simple-fields-using-within-wp_query-loop/#post-2333506)
 * Did you have any luck with fixing this – I’m just about to try some query’s using
   the custom fields from simple fields.
 *  [bryan042092](https://wordpress.org/support/users/bryan042092/)
 * (@bryan042092)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/plugin-simple-fields-using-within-wp_query-loop/#post-2333545)
 * Hi! did you guys solve this problem already?
 *  [sugardaddy](https://wordpress.org/support/users/sugardaddy/)
 * (@sugardaddy)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/plugin-simple-fields-using-within-wp_query-loop/#post-2333549)
 * You set an ID as a meta_key value…
    You can just write it like that : `$loop 
   = new WP_Query( 'post_type=rm_video&posts_per_page=5&orderby=title&meta_value
   ='.$category );`
 * Don’t forget to reset postdata after your loop :
    `endwhile; wp_reset_postdata();`

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘[Plugin: Simple Fields] Using within WP_Query loop’ is closed to new 
replies.

 * ![](https://s.w.org/plugins/geopattern-icon/simple-fields_fafafa.svg)
 * [Simple Fields](https://wordpress.org/plugins/simple-fields/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/simple-fields/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/simple-fields/)
 * [Active Topics](https://wordpress.org/support/plugin/simple-fields/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/simple-fields/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/simple-fields/reviews/)

 * 3 replies
 * 4 participants
 * Last reply from: [sugardaddy](https://wordpress.org/support/users/sugardaddy/)
 * Last activity: [13 years, 7 months ago](https://wordpress.org/support/topic/plugin-simple-fields-using-within-wp_query-loop/#post-2333549)
 * Status: not resolved