Skip Navigation

[Resolved] Create a view only with the first image of a ‘Repeatable group’

This thread is resolved. Here is a description of the problem and solution.

Problem: I have a Repeating Field Group (RFG) assigned to a custom post type called "Projects". I would like to use Views to show a custom field from the first RFG in each Project.

Solution: Use the "limit" setting in the View editor screen to limit the number of results that will be displayed in the View of RFGs, and use sorting to determine which RFG will be displayed.

Relevant Documentation:
https://toolset.com/documentation/getting-started-with-toolset/creating-and-displaying-repeatable-field-groups/#displaying-repeatable-field-groups

This support ticket is created 6 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 1.54 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 4 replies, has 2 voices.

Last updated by miguelG-5 6 years, 2 months ago.

Assisted by: Christian Cox.

Author
Posts
#1086548

Hi

I have a slider in the homepage of the site ( Flexslider in a view)

RIght now, the image is called from the featured image of à 'project'

I need to change the featured image for the first image a 'Repeatable group''

Can you please tell me how to call just the first image of the group ?

+Project 1
++Image 1
++Image 2
++Image 3

+Project 2
++Image 1
++Image 2
++Image 3

+Project 3
++Image 1
++Image 2
++Image 3

My slider should show the image 1 of every project..

Thanks

Miguel

#1087084
Screen Shot 2018-08-19 at 11.46.46 AM.png

Hi, here's the documentation for creating a View of a repeating field group:
https://toolset.com/documentation/getting-started-with-toolset/creating-and-displaying-repeatable-field-groups/#displaying-repeatable-field-groups

To show only the first image in each group, you should set the "Limit" of this View to be 1 (see the screenshot). If you cannot see the "Limit and Offset" section in the View editor screen, scroll to the top right corner and click "Screen Options". You can turn on the "Limit and Offset" section here.

#1088282

Hi Christian

A couple more quetions

If I create à view for the first image, when I insert that view into another view I get a DIV (with à bunch of code); How can I get a CLEAN URL ?

The loop from the 'first image' view should be something like this ?
<wpv-loop>
[types field='photo' size='slide-projet' item='@projet-photo.parent' url='true'][/types]
</wpv-loop>

_________________________
The code for the homepage slider is

<li data-thumb='[VIEW WITH CLEAN URL]' class='thumb' data-thumb-alt='[wpv-post-title] - Mutabilis'>
<img src='[VIEW WITH CLEAN URL]' alt='[wpv-post-title] - Mutabilis' tittle=' [wpv-post-title item="$current_page"] - Mutabilis' />

[wpv-post-title]
[types field='lieu'][/types] ( [types field='departement' output='raw'][/types] )

_________________________

Thanks a lot for your help

#1088450

We are working on a new feature that will produce View results with no extra markup (a raw View), but it's not quite ready yet. In the meantime, you can add this custom filter in your child theme's functions.php to strip all the extra markup from a View:

add_filter( 'wpv_filter_wpv_view_shortcode_output', 'prefix_clean_view_output', 5, 2 );

function prefix_clean_view_output( $out, $id ) {
  $ids = array( 12345 );
  if ( in_array( $id, $ids )) {
    $start = strpos( $out, '<!-- wpv-loop-start -->' );
    if (
      $start !== false
      && strrpos( $out, '<!-- wpv-loop-end -->', $start ) !== false
    ) {
      $start = $start + strlen( '<!-- wpv-loop-start -->' );
      $out = substr( $out , $start );
      $end = strrpos( $out, '<!-- wpv-loop-end -->' );
      $out = substr( $out, 0, $end );
    } else {
      $start = strpos( $out, '>' );
      if ( $start !== false) {
        $out = substr( $out, $start + 1 );
        $end = strpos( $out, '<' );
        $out = trim(substr( $out, 0, $end ));
      }
    }
  }
  return $out;
}

Change 12345 to match the numeric ID of the View you want to produce raw code. Then remove any extra spaces and line breaks from the View's Loop Editor and any Content Template used in the View.

#1096215

Thank you for your help.