WordPress.org

Ready to get started?Download WordPress

Forums

Simple Fields
Using within WP_Query loop (4 posts)

  1. katmac_aus
    Member
    Posted 2 years ago #

    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/

  2. Martin
    Member
    Posted 2 years ago #

    Did you have any luck with fixing this - I'm just about to try some query's using the custom fields from simple fields.

  3. bryan042092
    Member
    Posted 2 years ago #

    Hi! did you guys solve this problem already?

  4. sugardaddy
    Member
    Posted 1 year ago #

    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();

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic