Skip Navigation

[Resolved] Trying to list posts by date last modified, but show featured ads first

This thread is resolved. Here is a description of the problem and solution.

Problem:
How to output a View to show Featured posts first?

Solution:
If "featured" is from a custom field, you can order the View results by that custom field, then a secondary field such as post date.

In the client's case "featured" is determined by a taxonomy, which cannot be used for ordering, and so needs either two separate Views or a single View where the results of the query are manipulated before being output, using the wpv_filter_query_post_process filter.

Relevant Documentation:
https://wp-types.com/documentation/programmer-reference/views-filters/#wpv_filter_query_post_process

This support ticket is created 6 years, 5 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.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 2 replies, has 2 voices.

Last updated by Nigel 6 years, 5 months ago.

Assisted by: Nigel.

Author
Posts
#919635

I have a view that is listing my posts by Date Last Modified. There's a custom taxonomy called "featured." I'd like to always show posts with that taxonomy checked first. Essentially, making those posts "sticky." Is there a way to accomplish that?

Thanks

#919639

Thinking about this a little more, might a solution be to have two views - the first listing Featured posts, the second listing Non-Featured, but then have one filter that controls both views?

#919794

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi David

To achieve this with a single View you would need to use the wpv_filter_query_post_process filter, which makes the results of the View available before they are output. It will contain an array of post objects (the results), which you can perform a sort on to move featured posts to the top of the results.

hidden link

Or, yes, use two Views with the necessary Query Filters for featured.

If this is a custom search View, insert the Filter Controls in the first View, and reproduce the Query Filters for the search URL parameters in the second View.