WordPress.org

Support

Support » Plugins and Hacks » [Plugin: Simple Fields] Using within WP_Query loop

[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/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Did you have any luck with fixing this – I’m just about to try some query’s using the custom fields from simple fields.

    Hi! did you guys solve this problem already?

    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.