We have created a field called "is_concept" and we would like to show that at the top of a list view if possible.
Is there any way of doing this? It is the same post type we just want to show it at the top of the page
Hi, I can think of a couple of ways you might be able to set this up. To some extent it depends on whether or not this View uses pagination, and whether or not you want to include the featured items at the top of all pages or just the first page.
Does the "is_concept" field store a value to indicate negative, or only positive values? For example, does it store -1 for not featured and 1 for featured, or only 1 to indicate featured?
currently I am storing the values true and false. So some songs will show "is_concept = true" and that will need to show at the top. And then it will need to loop other items where is_key_song= True
sorry I just read the message again... There won't be pagination used as there will be the following per category:
- Concept Video (is_concept)
- key_song (is_key_song)
- key_song (is_key_song)
- key_song (is_key_song)
You can certainly set your View's order by to use one custom field as the primary sort order. If you cannot see the Ordering panel in the View editor, scroll to the top right corner of the screen and click "Screen Options". You can activate the Ordering settings here. Then you should be able to choose the is_concept field and adjust the sort direction as needed.
One thing to consider is there is primary sorting and secondary sorting. Only the primary sorting criteria will support a custom field in wp-admin. So if you need to order by one custom field first, then by another custom field secondarily, and some other fallback sort order after that, that will require custom code and our Views filters.
I have links to that documentation with examples: https://toolset.com/documentation/programmer-reference/views-filters/
Another thing to consider is a quirk of WordPress queries. If a post has no value for a custom field, and you try to filter or order by that custom field, the post will not appear in the results of the query. Only posts that contain some value for that custom field will be included in the results. The two workarounds here are custom code that modifies the view query, and custom code that saves some value for every post's custom field.
I hope this helps you decide how to proceed. Let me know if you have additional questions.