Looper provider filter by ACF value

i have an acf called “luogo”.
Inside a layout I would need to show 3 articles that have the same value of the current article.

I’ll explain.
in the article on this page:


I have the “luogo” field set as “Ceprano”.
In the lower section of the page (“Ristoranti vicini”), I should show 3 other articles whose “luogo” field equals “Ceprano”.

What type of looper provider should I use?
A thousand thanks

Hello @scenaryo,

Thanks for writing to us.

Please have a look at this thread to learn more about how to display the post-filter by the ACF meta field through Looper.

Hope it helps
Thanks

Hi @prakash_s,
I tried to follow the directions but it doesn’t work. I don’t just have to check if that additional field exists but I have to use its value as a filter…
Thank you

Hi @scenaryo,

Can you please provide login credentials for your site in a secure note to examine it further, including:

– WordPress Site URL & Login URL
– WordPress Admin username/password

To create a secure note, click the key icon underneath any of your posts.

Thanks

Hi @tristup,
I send you the credentials.
The problem is inside the section called “Luogo” which is inside the “dettaglio - DOVE MANGIARE” Layout.
Thank you very much

Hello @scenaryo,

It seems that you have not added the correct code in the query string. Please have a look at the given screenshot for settings.

dettaglio-DOVE-MANGIARE-Layout-Builder-Pro

Query String

posts_per_page=3&post_status=publish&ignore_sticky_posts=1&post_type=post&meta_key=luogo&meta_value=Ceprano&meta_compare=%3D&order=DESC

Please let us know how it goes.

Thanks

Hi @prakash_s,
thanks for the answer but I think I explained myself wrong: the meta_value must not be fixed (“Ceprano”) but must be the same as the one to which the current restaurant belongs.

For example, the “Opificio del Gusto” restaurant is located in Ceprano, so in the lower section of the page I will have to display 3 restaurants that are located in Ceprano.
But if I went to the page of a restaurant located in Florence, I would have to view 3 restaurants in Florence, and so on.

So the meta_value should be dynamic …

Hello @scenaryo,

In case the ACF meta value is not fixed then you need to compare the value with the dynamic meta value so you need to add the dynamic content code to pull the meta value and then it would compare the value and display the post based on the dynamic meta value.

Please update the query string like this.

 posts_per_page=3&post_status=publish&ignore_sticky_posts=1&post_type=post&meta_key=luogo&meta_value={{dc:acf:post_field field="luogo"}}&meta_compare=%3D&order=DESC

Please let us know how it goes.
Thanks

Hi @prakash_s,
it works like a charm!
Thank you very much!

Hello @scenaryo,

Glad that we were able to help you. Please feel free to open a new thread if you have any more concerns.

Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.