[Resolved] Designating a post as featured within a category
This support ticket is created 6 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Tell us what you are trying to do?
I have a CPT called Tools.
Tools has a Custom taxonomy called Tools Categories.
I would like to set a field that makes a Tool Post "featured" within a specific category - maybe in more than one category.
I know I can just make a checkbox field called Featured, but this would make the Tool featured in all categories. I want to be able to set the "featured" field separately per post and per category.
E.g.
Tool 1 is featured in category 1 and category 2
Tool 2 is featured in category 2 and category 3
Tool 3 is not featured in any category
I'm not sure how to do this with CPT and taxonomies - do I need to make another post type instead of my taxonomy and use relationships?
Is there any documentation that you are following? I've done some searches but nothing I've found covers this
Is there a similar example that we can see? Lots of directory sites do this
What is the link to your site? It's my client's site and is protected at the moment. If necessary I can recreate what I've done so far in a fresh install.
I've been giving this some thought but it is not so straightforward because unlike for Views, Toolset doesn't provide any filters to modify custom archive queries that we could use to manipulate what posts are returned and their sort order.
I'm going to take a break from this now and return to it later when I have attended to some other tickets in my queue and I'll get back to you when I can.
Thanks for looking at it. I see how to do it with another Custom Post type and a post relationship but it seems like overkill for achieving something that should be relatively simple. That would clutter up the admin area for the client and it's something I want to avoid if possible.
But saying that, the only solutions I can think of involve bad usability.
E.g. maybe I can add a field to the taxonomy. Into that field you would enter a comma delimited list of the post IDs that are featured in that category. Then somehow use that to sort so that the featured items appear first and are given a different class. In that case the user would have to find the post id for the featured item and enter it in a specific format into the taxonomy field. - not great usabilty.
Anyway, if you can come up with something I'd appreciate it. I've got a couple of weeks before it becomes urgent, and if we can't do it I'll just have to tell my client that featured means featured in every category.
The only thing you could use would be to orderby post__in where you perform a custom query to get the featured posts for that category, and work with the main query to manipulate these and create the post__in array from these, which you feed into the query arguments for a posts taxonomy query to be run a 3rd time, spitting out the results in the required order.
But even that doesn't help you style the featured tools distinctly.
I think this requires you writing a custom PHP template for the tool category archive that includes the custom queries and where you have control over the output so that you would be able to style the featured tools within the category differently.
Apart from setting up the initial taxonomy, I don't think Toolset can help getting the result you want for the output.