1

I have a Custom Post Type (CPT) named "Events", and I want to add a Query Loop on my front page that displays the upcoming events that my website visitors may want to participate in. On the "Post Type" setting of the Query Loop, I only saw two choices: "Post" and "Page". However, I heard Query Loop can be used with CPT too and I saw a YouTube video showing a Query Loop with CPT options (screenshot below).

Screenshot: Query Loop with CPT options

The video itself does not cover how to apply CPT on Query Loop, so I tried googling for some tutorials. I found this article which may contain the solution I need; the thing is it requires NodeJS which I am not familiar of.

So I wonder if there is any alternative solution to this. Perhaps PHP code that does not require NodeJS? Or a certain plugin that I can install? Thank you in advance!

3
  • is e.g. show_in_rest set as true when you define your cpt?
    – birgire
    Aug 22, 2023 at 9:21
  • 1
    @birgire Wow thank you very much! I just typed in show_in_rest and set it as true, and now it works! :D
    – mawgumelar
    Aug 23, 2023 at 2:16
  • Good to hear it worked. I posted it as an answer.
    – birgire
    Aug 23, 2023 at 9:24

1 Answer 1

0

The post-type dropdown in the Query Loop block is populated with data from the REST API endpoint:

/wp-json/wp/v2/types

so we have to make sure the public custom post type is registered with show_in_rest as true for it to be included within that data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.