Simple Fields
[resolved] Getting images in repeatable fields (3 posts)

  1. sugardaddy
    Posted 3 years ago #

    Hi !
    I thought I was right with this code :

    $major_features = simple_fields_values("major_feat_title,major_feat_image,major_feat_link,major_feat_anchor");
        foreach ($major_features as $major_feature) {
            $file_id = simple_fields_value('major_feat_image');
            $image_info = wp_get_attachment_image_src($file_id, "full");
            $image_url = $image_info[0];
            $post_id = simple_fields_value('major_feat_link');
            $post_url = get_permalink($post_id);
            echo "<li style='background-image: url($image_url)'><p>" . $major_feature["major_feat_title"] . "</p><a href='$post_url#" . $major_feature["major_feat_anchor"] . "'>" . __('En savoir plus',superprotobeef2) . "</a></li>";

    But I get only the image of the first occurrence repeated for each...

    Thanks for your help !


  2. Pär Thernström
    Plugin Author

    Posted 3 years ago #

    You should have all your info in the variable $major_feature in each loop already, so in the loop you should be able to do:

    $file_id = $major_feature["major_feat_image"];
    $post_id = $major_feature["major_feat_link"];
  3. sugardaddy
    Posted 3 years ago #

    That does the trick !!
    Thanks a lot.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Simple Fields
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic