ACF in query

I inserted an image with dynamic content.

The source is:

2022-11-16_104253

I tried to set LOCATION to “Post ID”, “Current Post”
but the image always stays empty.

What is wrong? Is there a solution?

The PHP code to display the image is:

<?php
$field = '';
$fields = '';
$fields = get_field('clubrecevant');
if( $fields ) {
		foreach( $fields as $field ){
				$field_id = $field->ID;
				$image = get_field('_thumbnail_id', $field_id);
				if( $image ) {
					$thumb = $image['sizes'][ 'thumbnail' ];
					echo '
					<div>
						<img src="' . esc_url($thumb) . '" width="75px" height="auto"  />
					</div>';
				}
		}
}
?>

If you leave location as current (basically not touching it) you should be fine
as the image you are looking for is in the current query ( I imagine you are in a template)
just give it a second and the image will show up if you set the Dynamic Preview

@JuGa Thank you for answer
But here is the issue (backend and frontend):

  • with image and above settings (Current OR Post ID OR Current Post → nothing is displayed
  • with the PHP code block → no issue, the image is well displayed

2022-11-16_104253

in your acf image field
what is the return format?
if you use Image Array or Image URL it should work fine

You shouldn’t need any php code block to just display an image from an ACF field

I do agree with yu and that is the reason why I want to replace my PHP code by the correct dynamic settings of the image.

Here are the ACF sttings of the image:

So you are trying to display a feature image of a linked posted via a relationship
ok I didn’t face that case yet but I think that is where the problem comes from

Did you try
Location POST ID
then in the location ID add your relationship ID for which you might need a fudtion though
maybe @louis can tell us if that case have been though through so far… :thinking:

I see what you mean, but I don’t know nothing about the relationship ID.
I know that the type “Relation” is a bit touchy.

Yes I am trying to check your issue
as I am interested in the possibility to use relationships
I remember working with them in elementor or oxygen without much problem, really hope it will be the case with Cwicly as well
Going back to my investigation and coming back to you asap…

I will try by myself too
The first one who find anything will post here
Cheers

to my understanding the logic would be using a query block with a meta query of your relationship
and inside the query template display an image set to dynamic/worpress/featured image
I haven’t been able to get the query right so it can display anything yet…

does that sound like the correct path?

I found this in a previous post by @louis on the relationships

The truth is there is so much we can do with Cwicly, and so much is added everyday through updates, but without in detail documentation including case studies, it is hard to follow up…

almost there
:crossed_fingers:

The main query is set to “product” or whatever CPT.
The ACF group is linked to this CPT
Inside the group there is an ACF field with relation to the featured image of another CPT. I want to display this image.
According to these prerequis, I can’t figure out to set a query block with meta query.
I need to dig deeper in Cwicly queries.