advanced-query-loop icon indicating copy to clipboard operation
advanced-query-loop copied to clipboard

Custom post type, Query Builders greyed out

Open frspp opened this issue 3 months ago • 5 comments

Hi!

Thanks for the plugin! A problem: I'm trying to show Post type: self-made custom post type and would need to filter with Post Meta. When Post Type is this custom post type, both Query Builder buttons are greyed out. Wonder why is this?

WP Version 6.8.2 AQL Version 4.3.0

Image

frspp avatar Sep 14 '25 09:09 frspp

This is happening to me too on version 4.3.0. Also broke meta queries that were previously working on 4.2.0. Temporary workaround is to downgrade to 4.2.0.

itsamoreh avatar Sep 17 '25 19:09 itsamoreh

Thanks for opening this. Can you confirm that there are both taxonomies and post meta registered to the custom post type? In each case, the control checks for registered meta (in the case of the Post Meta builder) and taxonomies associated with the post type and disables the button if they are not found.

ryanwelcher avatar Sep 19 '25 13:09 ryanwelcher

@ryanwelcher in my case, here's how I'm registering an event start date meta field on my event custom post type:

register_meta(
	'post',
	'abc_events_start_date',
	array(
		'show_in_rest'   => true,
		'single'         => true,
		'type'           => 'string',
		'object_subtype' => 'abc_events',
	)
);

I'm using object_subtype to register it to the custom post type abc_events specifically.

Then I was using an AQL meta query to sort the posts by the event start date instead of by the post date.

This was working great on version 4.2.0 but broke on 4.3.0. On 4.3.0 the "Post Meta query builder" button is greyed out and the events have reverted back to being sorted by post date.

itsamoreh avatar Sep 19 '25 14:09 itsamoreh

Thanks for the follow up @itsamoreh. I've not seen post meta registered like that. Are you registering the meta to both the post and the abc_events types?

I just tested this out and it seems that post meta registered in this fashion doesn't show up in the REST response in the Block Editor - which explains why the query builder is greyed out as it thinks there is no meta assocated.

ryanwelcher avatar Sep 19 '25 14:09 ryanwelcher

While digging into this I found a bug in the way the post meta is being discovered that may also contribute to this. See #140.

ryanwelcher avatar Sep 19 '25 14:09 ryanwelcher