We build up a site with different CPTs and one of them is „Products“.
There is one site for all products shown with a view incl. a search block. The search block consists of taxonomies about the products.
Some of these products are sponsored. This is also a taxonomy but limited by time and not shown in the search block. So we have to show them on top of the view.
We know, that it’s not possible to sort a view by taxonomy. And we tried different things, but nothing really worked the way we need it.
So is there any workaround to show all products sort by date and on top the sponsored products incl. one search block for all?
Hello. Thank you for contacting the Toolset support.
I would like to know first - are you using Toolset Blocks or Toolset views to build your views?
In addition to that - if you are using a classic view then I think we can workaround it by adding a two views but first of all I will have to check your current structure and all.
Can you pleas share problem URL where you want to implement it and share admin access details.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
Ok now I'm able to login to admin. Thank you for sharing working admin access details.
Now, issue is, you can not sort posts by taxonomy term. You can sort posts by custom field.
I see you created custom search view and the post you mentioned (hidden link) that is also a part of your view's result currently when we load the page on frontend:
=> hidden link
As I got understand now, the issue is you want to display the product (hidden link) at top of the result as its been marked as sponsored using taxonomy term. But as I said, you can not sort posts by taxonomy term but using custom field.
I suggest, either you should create custom field that holds the sponsored value and then sort by using this custom sponsored field instead of taxonomy.
If the above option does not suit you and you still want to use the taxonomy term to order the posts then it will require using hooks and custom code that you will require to write. Please check this related ticket, this will not be the exact solution but you will get idea what kind of custom code and hooks you will require to use.
=> https://toolset.com/forums/topic/ordering-a-parametric-search-view-by-taxonomy/#post-617416
The issue is that we're not able to limit a CF by time as the products require.
Maybe it's possible to connect a CF to a taxonomy ?
The idea is to check the taxonomy and the created CF holds sponsored value automatically until the taxonomy expires.
The thing is that you can order post by post custom fields and you can order taxonomy terms by term custom fields.
Maybe it's possible to connect a CF to a taxonomy ?
==>
You can add a term custom field to your taxonomy but again you can not order posts by term custom fields. This is by design of WordPress.
If you want to sort/order your posts based on taxonomy term, you will have to use the filters and custom code as I shared with my pervious reply where you will have to use filters and custom code.