Skip Navigation

[Resolved] Accessing images from field group on different page that is not the post via ID

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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 2 replies, has 2 voices.

Last updated by Minesh 1 year, 8 months ago.

Assisted by: Minesh.

Author
Posts
#2654457

Hi,

I'm trying to access images that are stored in a repeatable field group (group slug: gallery-group, field slug: gallery-image)
EDIT: I want to access the images on a different page via the post id.
I'm prett sure my settings in Toolset are ok, because on the page that displays the post itself i can access the images just fine.

I tried the solution that was mentioned here:
https://toolset.com/de/forums/topic/looking-to-display-images-from-image-field-by-post-id/

The problem described there seems to be my exact usecase. However the code shown there didn't solve my issue:
<?php echo types_render_field( "images", array( "alt" => "", "size" => "thumbnail", "id" => 10 ) ); ?>

I replaced "images" with the field slug and group slug, and tried it with a ID that I know to have contents. But I get not output at all.

Is there a easy way to access/display those images in full size?
Thank you so much in advance, I'm really stuck on this problem.

Best
Jannik

#2654467

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Do you want to display repeating field group item field (image) using PHP? If yes:
- Here is the doc that you should try to follow:
=> https://toolset.com/documentation/customizing-sites-using-php/displaying-repeatable-groups-of-fields/

If that does not help, please share problem URL and admin access details and tell me at what place you want to display what repeating field.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2654513

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I've added the "File Manager" plugin so that I can access the theme files. (You can remove as required).

I've adjusted the code to "page-signage.php" PHP file as given under:

$child_args = array(
    'post_type' => 'galerie-stuecke',
    'numberposts' => -1,
    'order' => 'ASC',
    'toolset_relationships' => array(
        'role' => 'child',
        'related_to' => 5960,
        'relationship' => 'galerie-stuecke'
    )
);
  
$query = new WP_Query( $child_args );
$child_posts = $query->posts;

foreach ($child_posts as $child_post) { ?>
          
<div class="car-listing">
        <h5><?php echo $child_post->post_title; ?></h5>
        <?php echo types_render_field( "bild-galerie-stuecke", array( "item"=> $child_post->ID, "size" => "thumbnail" )); ?>
    </div>
  
  
<?php } 

When you want to query repeating field group posts, the post type you should query is 'galerie-stuecke' as the repeating field group slug 'galerie-stuecke' is considered post type and post relationship slug as well.

You can adjust your code as required for $child_posts foreach loop.

#2654515

Thank you so much for the fast help.
I really appreciate it. Have a good day!

Jannik