simple_fields_fieldgroup

simple_fields_fieldgroup – Retrieve values from all fields in a field group.

This function works like a shortcut to running simple_fields_value(slugs) with all slugs already entered. Depending if the field group is repeatable or not, simple_field_value or simple_fields_values will be used.

Description

mixed simple_fields_value( string $field_slug [, int $post_id, mixed $options] )

Parameters

field_group_id_or_slug
The slug or the is of the field group that you want to get all field values for.

post_id
Id of the post to get values from. Defaults to the current post in the loop.

options
An optional set of options as array or query string to send to field type. This is a way to send options to the field type so it can modify values before return, or modify the output in any way. So far, only a few field types support options.

Return value

Mixed, but probably array, depending on how many field the group has (just one field, and not repeatable = no array for you!)

Example

$field_group_values = simple_fields_fieldgroup("myFieldGroupSlug");
print_r($field_group_values);

// Output of above (in this case information about a video)
Array
(
[video_url] => http://www.youtube.com/watch?v=eqnj19LDGqQ
[external_likes] => 3
[external_views] => 572
[date_uploaded] => 2012-01-06T04:45:45.000Z
[date_updated] => 2012-10-27T13:47:40.000Z
[youtube_title] => GoPro HD HERO2
[youtube_description] => Testing my new GoPro camera.
[youtube_duration] => 181
[youtube_comments] => 1
[youtube_thumbnail] => http://i.ytimg.com/vi/eqnj19LDGqQ/hqdefault.jpg
[video_location_lat] => 63.42393641810853
[video_location_lng] => 12.96202958164065
)

11 thoughts on “simple_fields_fieldgroup

  1. Brian

    Is there a typo on this page? At the top I think the example should be “simple_fields_fieldgroup” rather than “simple_fields_value”

  2. pradeep

    i need to getting fields when i’m trying this ” http://aszrevamp.aszstaging.com/api//?field_group_values = simple_fields_fieldgroup(“inner_sec”) “……i’m getting like this…
    {
    status: “ok”
    json_api_version: “1.1.1”
    controllers: [2]
    0: “core”
    1: “user”

    }

    But i’have to get all details that i’m not getting….
    will anyone explain or send me how to do that to get fields……

  3. kevin

    How can we retrieve and display two or more field groups in one post? I’ve got two groups within my posts and the function simple_fields_fieldgroup(); only works once for the first call when written like this:

    $imgsbottom = simple_fields_fieldgroup(“cfsf_event_galeria”);
    $vidssbottom = simple_fields_fieldgroup(“cfsf_event_videos”);

    Any clue?

    1. kevin

      Found the trick. I had this:

      $imgsbottom = simple_fields_fieldgroup(“1”);
      foreach(1)
      $vidssbottom = simple_fields_fieldgroup(“2”);
      foreach(2)

      and calling the the second group right below the first did the trick, no idea why:

      $imgsbottom = simple_fields_fieldgroup(“1”);
      $vidssbottom = simple_fields_fieldgroup(“2”);
      foreach(1)
      foreach(2)

  4. Chris

    How would i incorporate this into

    <?php

    $selected_value = simple_fields_get_post_value(get_the_id(), array(1,1), true);

    $theImageURL = wp_get_attachment_url($selected_value);
    echo '’;
    ?>

    to show multiple images from the 1 post connector

  5. Tim

    How do I output a repeatable fieldgroup (in other words echo it with all the values it holds) on a page? The above doesn’t really tell me. Thanks.

Leave a Reply