Why are some custom post types not selectable for Query Loop

Hi, I have been using Tom’s WP Show Posts for years. I would now like to replace it with the Query Loop of GenerateBlocks. However, I ran into the following roadblock:

My site has 3 custom post types, 2 are added by 2 plugins I use, 1 I created via the plugin Custom Post Type UI and added the generated code in functions.php before deleting CPT UI again. All 3 custom post types function normally on the site. In WP Show Posts I can select any of the 5 post types: post, page, hb_accommodation, sdm_downloads, extra. The Query Loop dropdown only gives me: Posts, Pages, Accommodation. Also note that WPSP apparently looks at a different list than GB Query Loop, seeing the different wording.

Why are the last 2 custom post types missing from GB Query Loop and how could they become available to select?

Hi Theo,

Can you try rebuilding your permalinks?

You can refer to this article for assistance with regards to this: How to Regenerate Your Permalinks in WordPress

Kindly let us know how it goes.

Hi Fernando,

I now did this, but that doesn’t change anything. Normal permalink structure was “postname”. I changed to numeric and saved. That broke my site, of course. Query Loop still only showed “Post, Pages, Accommodation”. I then changed permalink structure back to “postname” and saved. Website was back to normal. Query Loop still shows “Accommodation” as only custom post type next to posts and pages.

I believe that GenerateBlocks is somehow looking at a different part of the WP databases than WP Show Posts. WPSP displays the short names for the custom post types and sees all three, GB displays the long names and sees only one. I don’t know if that helps; I’m not fluent in WordPress technicalities…

If the Post type appears in the REST API, it should appear in the options available.

Can you check if there’s ”show_in_rest" => true, in you code?

Can you check if there are any differences in the settings of the CPT which is showing and the one that isn’t?

Moreover, the post type select option in the Query Loop Block shows the Plural Label, and WPSP shows the Post type slug.

Kindly let us know.

Hi Fernando,
That’s it! “show_in_rest” was set to false in the PHP code for this custom post type. After setting it to true, the plural label of this custom post type is selectable for the Query Loop. That solves my issue, as I have no need to run a query loop for the other custom post type not showing up, the one generated by a separate plugin for managing downloads. Thank you very much!

You’re welcome @Theo! Glad it’s working now!