I’m trying to implement a custom sorting for my custom post type based on the order of a taxonomy on an archive page. My goal is to have the posts sorted according to the taxonomy terms (using a predefined order) and applied immediately on page load, without needing any button clicks.
I’ve experimented with various approaches:
• Adjusting the query via standard WordPress filters (pre_get_posts, posts_clauses, etc.)
• Using a meta key to store a custom sorting value and then ordering by meta_value
I’m also using Gridbuilder facets for filtering. However, my attempts with the meta key approach have resulted in no posts being loaded, and my query modifications don’t seem to have any effect.
Has anyone experienced a similar issue or found an alternative approach to achieve this taxonomy-based sorting? I’m open to completely different solutions as well.
I am using WP Gridbuilder with a CPT to sort by Taxonomy terms and this works perfectly. So I think this has to do with your settings. Can you share some screenshots of your settings?
I use Gridbuilder as a filter (facets). Previously, sorting using the BricksBuilder loop function (order by) was sufficient. But now that’s no longer possible because I need sorting using a taxonomy.
I’ve taken another look at Gridbuilder and I can create a sorting filter there. But you have to click on it, right? But I’d like to have the sorting when I open the page.
I am not really sure what you mean by: But you have to click on it, right? But I’d like to have the sorting when I open the page.
What you need to do is create the sorting filter (facet) in Gridbuilder and then you add the 'facet’element to the page/template with the CPT items that needs filtering.
Sorry that I didn’t express myself clearly. I didn’t know that I could create a filter in Gridbuilder that works when the page opens. Gridbuilder beginner, I only used it for filtering. I’ll definitely take a look at it. I’m just a bit overwhelmed with the go live of a page.
If you can give me a tip about the settings, or maybe a screenshot of what I need to look out for, that would be great.
In any case, thank you for your answers and help. It was useful for me.
Sure… so my facet looks like this (partially). So I want to filter my CPT posts by ‘merken’ (this is Dutch for brands). The user can ‘checkbox’ a brand to filter.
Thanks for the screenshots. Netherlands, then we are not that far apart. But as for the screenshots, they refer to a filter and not to a sorting. I have no problems with the filters. I am concerned with the sorting of the articles. When I open a page, the articles should be sorted according to a certain taxonomy.