WP query array not quite right

So my current query is: post_type=tribe_organizer&p={{dc:post:meta key="_EventOrganizerID" multiple=“true”}}

But that’s not the correct way to format the query of “get tribe_organizer posts 1,2” because p is for a single value, not an array! (that dynamic content tag does correctly output a comma separated list.)

I went through the wp query docs and tried walking through a query builder tool to help me get my syntax right… but i’m just missing something! I think it’s the translation to a string that’s tripping me up. Could I get some help with this please?

On a related note, is there any plan to add a dynamic component to the query builder’s “specific posts” filter? It seems like just the thing to solve these kinds of issues.

Hi @glindacreative,

Thanks for reaching out.
While using multiple post IDs, you need to use the post__in parameter. You need to create an array of arguments for the Query and then just use the http_build_query function to format it into the Query String.



Hope it helps.
Thanks

The note in thread two about var dump putting the formatted query at the top of the dashboard was helpful, I hadn’t understood that before! (I was worried I’d have to create a custom page or it’d show on the front end, etc. so I’d avoided using it and have hand written all my more complex queries!)

Something still isn’t quite clicking.
this query -
$query_args = array(
‘post__in’ => array(’{{dc:post:meta key="_EventOrganizerID" multiple=“true”}}’),
‘post_type’ => ‘tribe_organizer’,
);

becomes this output
5D=%7B%7Bdc%3Apost%3Ameta+key%3D%22_EventOrganizerID%22+multiple%3D%22true%22%7D%7D&post_type=tribe_organizer

I did this one by hand so it’d be a little neater, pretty sure the syntax is right - post_type=tribe_organizer&id_query%5B0%5D%5Bpost__in%5D={{dc:post:meta key="_EventOrganizerID" multiple=“true”}}
(Also tried with single quotes just in case.)

Both of these just return a long list of that post type, not related to the post the meta key is being pulled from.

Putting the dynamic tag in the page body (element directly above my query box) does output the right info, one or more ID values, separated by commas. Did I somehow skip a step or mess up the syntax?

Hello @glindacreative,

Do the {{dc:post:meta key="_EventOrganizerID"}} returns an array? You can use this instead:
post_type=tribe_organizer&post__in%5B0%5D={{dc:post:meta key="_EventOrganizerID"}}

If this do not work for you, please provide us with your WP access so we can check your custom fields and your looper settings. You can create a secure note in your next reply with the following info:
– Link to your site
– WP login URL
– WP username
– WP password
– WP Administrator Role
– Confirmation that we can access and make changes to your site

To know how to create a secure note, please check this out: How The Forum Works

image

Best Regards.

1 Like

Secure note added to OP. Thank you for checking into this for us!

Hello @glindacreative,

The {{dc:post:meta key="_EventOrganizerID" multiple=“true”}} returns a string array. With this, you must have a nested Looper with the following structure.
Screenshot 2024-06-28 at 10.41.02 AM

Looper Provider String `{{dc:post:meta key="_EventOrganizerID" multiple="true"}}` / Looper Consumer
     Looper Provider Query String `post_type=tribe_organizer&p={{dc:looper:item}}`
         Looper Consumer Headline element.

And the result will be like this:

Best Regards.

1 Like

Oh wonderful!!
Thank you so much for taking the time. This will absolutely be useful in the future, too.

Could you do me one favor and edit out that last results screenshot? It’s a client privacy thing. Much appreciated!

Hi @glindacreative,

Glad that we are able to help you.

Thanks

1 Like

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