Support » Plugins and Hacks » [Resolved] Accessing simple-fields in get_posts loop

[Resolved] Accessing simple-fields in get_posts loop

  • I can access the simple-fields values via:

    %p.event-description= simple_fields_value(‘test’)

    in the main have_posts() loop, however when I’m using:

    – $recent_events = get_posts(…)

    The simple_fields_value(‘test’) does not retrieve my simple fields value. Any ideas how to get this to work in my secondary loop?

    Thanks for looking!


Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Pär Thernström


    Depending on the way you loop, this is one solution:

    foreach ($recent_events as $one_event) {
      $value = simple_fields_value('test', $one_event->ID);

    Ah, thank you. Specifying the ID explicitly helps.

    Plugin Author Pär Thernström


    Yes, but as I said, it all depends on how you do the loop. If you did the loop using wp_query() then you would not have to use the id explicitly. Then your first try would work, something like:

    $custom_query = new wp_query($query_args);
    while($custom_query->have_posts()) : $custom_query->the_post();
        $value = simple_fields_value('test');

    Excellent, thanks for the explanation. I’m new to WP so I’m still learning the nuances of defining multiple loops and such. A new instance of WP_Query seems reasonable.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] Accessing simple-fields in get_posts loop’ is closed to new replies.