• 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 !

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    How much we can customize existing blocks is outside of my knowledge base. I suspect you’d be better off building your own custom block. You could use the query loop source code as a starting point.

    You might instead consider building a custom pattern or template to achieve what you want.

    I’d be leery of relying upon tags for filtering since their creation is free form where multiple tags could all represent the same attribute. This will cause relevant items to not be found in a filtered query. IMO it’s be better to assign pre-defined terms so the relevant term is always the one used and not some random variant that means the same thing. The tags used in these forums is a great example of this problem. There are thousands of different tags people have created, many synonymous with other tags. Attempting to query for topics with a particular tag will likely only return a small portion of relevant topics. There has been discussion about removing topic tags altogether or severely restricting which tags could be used.

    @bcworkz i dont agree with you.

    you can achieve the desired result with just AJAX that will filter the posts via tags.

    Moderator bcworkz

    (@bcworkz)

    Differing opinions can be beneficial to a topic ?? I agree that it can be done. I do not agree that tags are the best way to filter posts. Of course there may be exceptional cases where they do make sense. It depends upon who is assigning the tags.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.