Custom block to filter custom post archive page with AJAX
-
Hello everyone.
I’m a adding a custom post type to my website. Those posts (I’ll call them “tips”) will contain a title, short content (text, some with an embed video) and assigned one or several tags. I want to display them in a very specific way, kind of like a product page : all posts are displayed by default, and users can dynamically filter the list :
- by tags, by selecting one or several tags (if no tag is selected, no filter is applied, and when several tags are selected, the list is filtered on those tags)
- by content (with/without video)
- I am also considering adding a searchbar, but for now it seems overdone with the tags
I have already defined the post-type and the custom field that will be used to indicate whether or not the post contains a video.
I know there are plugins that could do what I want to do, but most of them aren’t free and the few that I tried don’t offer exactly the result that I want when it comes to layout. Also, I am simply interested in understanding how that works, so I would like to try doing it myself.
I was thinking of building a custom block to display the tags and with/without video option, that would send the defined filters in AJAX, but I am not sure about how that would interact with the query loop block that displays the posts in the archive page. Is it possible to update the query loop block dynamically with data sent in AJAX ? If so, how should I proceed ?
Thank you in advance for your help !
- You must be logged in to reply to this topic.