Forums › Forums › Search & Filter Pro › Featured posts
Tagged: featured posts, ORDER
- This topic has 10 replies, 2 voices, and was last updated 7 years, 6 months ago by Anonymous.
-
Anonymous(Private) May 15, 2017 at 10:09 am #108797
Hi
I’m trying to make some (2-3) key products appear at the top of every search and filter. The other search results should appear in alphabetical order by post title.
Apologies if this is a duplicate post, but I can’t find anything that helps. I’ve several things but with no luck, including Relevannsi.
Many thanks!
David
Trevor(Private) May 15, 2017 at 3:41 pm #108855You would probably want to set up a Custom Field (e.g. in ACF) and make it Boolean (On/Off, True/False) called ‘featured’
Then change the sort order to have that field sorted first.
But, beware of two things:
1. You will have to set a default value for all posts (probably ‘off’) AND edit every post to set this, otherwise any post not so set will disappear from the results completely.
2. They will still be subject to any filter you make, and might therefore not always appear.
Anonymous(Private) May 15, 2017 at 4:26 pm #108890Thanks for the quick response. I have tried this before so gave it another go but still, I can’t get it working.
Two products are checked as being a ‘Key Product’ but only one is appearing on top and the rest are not sorting alphabetically.
I have set the Default Order (beneath ‘posts’ tab) to the true/false meta key of field created in ACF and ascending (also tried descending).
Anonymous(Private) May 16, 2017 at 7:22 am #109039Yeah, I set the secondary sort to sort by Title (presume that’s correct – I have played with other options) but then none of the featured posts appears at the top.
I’ve noted your two gotchas – all posts are appearing on the page, just not in the order I’m expecting.
I’ve been playing with these for a while and can’t get them working as I think they should be.
Trevor(Private) May 17, 2017 at 4:00 pm #109438OK. I can see you are using a theme template, but I am unable to edit that and see its code content. If you can, open it up and see if you can see where it is passing the query arguments to the wp_query. The theme must be overriding the sort order in our query/filter.
Trevor(Private) May 18, 2017 at 11:28 am #109650OK.
So, fresh eyes and I spotted the issue. Three errors. You had
Maintain Search Form State
On – not a good idea unless you need it. It is now off. You had the wrong meta key name. ACF key names do NOT start with an underscore_
. Fixed. The sort order needs to be descending. Fixed. -
AuthorPosts