- This topic has 2 replies, 2 voices, and was last updated 4 years, 7 months ago by mengland.
October 8, 2018 at 7:18 pm #60844menglandParticipant
I’m currently developing a post feed block that works with custom post types and taxonomies to display a post feed. I can get my custom post type to display in the editor and the taxonomies to appear in the category selector. However, if I select a taxonomy the post list in the editor does not change, which tells me it’s something with
latestPostsQueryin the edit.js file. I’ve tried many combinations of query modifications but haven’t had any luck.
I tried reaching out on the core editor slack, searched through Gutenberg Github, and have done a lot of googling without any luck. If anyone has any helpful information that could point out what I’m doing incorrectly I would be very grateful.
Here is my working files for this block, it’s based on the Latest Posts block.
CPT Post Feed Working Files
Thanks,October 8, 2018 at 9:24 pm #60871Zac GordonKeymaster
I took a quick look at the code, but on the event handler for handling the selection of checkboxes can you at least get something to trigger so you know that part is working. For example log out what the new request is along with the modified query results.
Also can you mock it up to give you a custom query from the start by hardcoding it like one of the custom taxonomies have been selected.
Just thinking of a few ways to begin troubleshooting.October 10, 2018 at 1:22 pm #61184menglandParticipant
Thank you for the advice. Luckily all of the toggles and control panel settings worked perfectly before hand. So, I took your advice in a little bit different direction to try and narrow down what I could change in the query versus what didn’t work. I searched through the Gutenberg repo and didn’t find too many helpful bits that actually altered the query which led me to ask where the query keys and terms originated from. Long story short the answer involved referring to the Rest API Documentation.
When I looked at the term
categoriesin the document it said “The terms assigned to the object in the category taxonomy”. I then added
hms_event_types: categoriesto change the endpoint to match my taxonomy. Everything worked like a charm after that. The
categoriesconstant returns an integer for the post id which fixed the post query displayed in the editor.
Just wanted to share this bit of information in hopes that it might help save time.
Here is the updated version of my block
Event Custom Post Feed Block
- You must be logged in to reply to this topic.