Looper Query String where ACF meta_key is on a Page

I am developing a “story” website where the Authors are outsiders. Each Author has its own showcase Page, where it showcases only the Author’s post. So I have a template Page where I will use to create for any new Author that signs up.

I am using Loopers to showcase different posts in different categories. I have 6 post categories, e.g. horror, comedy, gut-wrenching, etc. So each Looper is 1 category.

  • Story
    – Horror
    – Comedy
    – Get-Wrenching

Every time I create a new Page for an Author (from a template), I have to go to individual Loopers and configure 6 times to filter just the Author. That’s a pain.

My solution is to create a taxonomy custom field (via ACF) on the Page. Assign the taxonomy custom field to the Category that is for that specific Author (i.e. every Author has its own category)… so that the 6 Loopers do not need to be reconfigured.

  • Authors
    – Author1
    – Author2

For the Looper Provider, I want to use a Query String. The custom field is called “artist_category” on the Page. So my Query String looks like this:

cat=45&meta_key=artist_category
(cat=45 is Comedy)

This, unfortunately, does not work (even though the syntax is correct). I believe it is because the ACF is on the Page (not Post). Would you have any suggestions on how I can make this work?

Hi @sgchan,

Thanks for reaching out.
It will be very difficult to understand the problem without investigating it from the WordPress admin dashboard. Can you please provide login credentials for your site in a secure note to examine it further, including:

– WordPress Site URL & Login URL
– Exact Page URL where you are having this issue
– WordPress Admin username/password

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

Thanks

Hi @sgchan,

I have checked the page but didn’t find the Looper Provider for Free Content and the Author. The Looper Provider for posts is only found. I would suggest you use the Layout Builder to create a Single Layout and assign it to the Author roles as shown in the given screenshot.

So it will be automatically showing the content related to the specific Author and you don’t need to create different pages for different Authors. I would suggest you go through the following article and videos on Layout Builder and Single layouts. You need to go through the Condition and Assignment documentation to assign the layout properly.



Hope it helps.
Thanks

Hi @tristup,
Did you find the ACF field? The Looper is Row7 as shown below:

Unfortunately, I cannot use Layouts because every Author’s design (e.g. background image + colour scheme) is different.

Hi… I’ve figured out what went wrong… I needed to pass in 2 categories into the Query String… not use meta_key.

Can I ask how can I use category__and in the Query String please?

Hi @sgchan,

Glad that you are able to figure that out. You can use the category__and as per the specified structure in the Query String. I would suggest you go through the following article on this.

Hope it helps.
Thanks

Thank you for responding back… Ha ha, I am looking at the exact same article. The category__and requires an array… Query String doesn’t accept arrays. How do I get it in?

I have also tried the below combinations but failed…
cat='19,45'
cat=%2719,45%27 (with percentage encoding)

Is there a way for Query String to handle more than one categories?

Hi again @tristup
I have also found this past posting asking a similar question…

It is a similar scenario where post_type receives an array. So I created something similar with cat

category__and%5B0%5D=19&category__and%5B1%5D=45

EUREKA!!! It works! That’s how you enter an array.

Thank you for your patience and kindly mark this case as closed.

You are most welcome @sgchan

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