Skip Navigation

[Resolved] Create a Featured section in the CPT archive

This support ticket is created 4 years, 7 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Tagged: 

This topic contains 3 replies, has 2 voices.

Last updated by bastienB 4 years, 7 months ago.

Assisted by: Beda.

Author
Posts
#1340279

Tell us what you are trying to do? Have one post stand out in a featured section above the archive results.

Is there any documentation that you are following? No.

Is there a similar example that we can see? Not that I'm aware of.

What is the link to your site? hidden link

---

I have added the "Featured" value as a custom field (checkbox).

I have created a view that returns 1 post only and look for a post that has the custom field "Featured" as a "Boolean" with the value "1" and "Expiration Date" is a "Date" that is "Greater than TODAY". The promotion "CUSTOM VALUCAP DAD HATS
AS LOW AS $6.47/EA." should match these parameters but nothing is returned. I also tried "Lower than TODAY" but it doesn't work either. Maybe the date is not properly stored in the custom field? It looks like a string currently...

Another thing is that I'd like the currently featured post to be excluded from the main results... but if there are more than one post set to "Featured", only the one that is currently displayed should be excluded from the results. I could set a query filter but then it would automatically exclude all posts that are "Featured". Would there be a way to only exclude the post currently displayed in the Featured section?

Thank you!

#1340285

Update; I found a solution for the first part of my question, which is to get the post to display. It's a bit counter-intuitive as I have to choose "Number" and not "Date" in the query filter.

Now, is it possible to exclude only the post that is currently featured and displayed from the results?

#1340337

It's not possible, but that is not because Toolset does not allow it, it's because logically a query that asks for items X by a value Z, will always return those Items with that value.

To exclude that one post which is already displayed I would use an HTML condition instead.
That means, get the Post ID of the one displayed featured Post and compare it in an HTML condition in the archive loop against the current posts in that loop.

If not matching, display the posts, and if matching, hide - so you will not see the one featured post twice

To get the ID of that post, simply create an identical view and return the (one) post id in raw mode, for example.

Please let me know if something is not clear to achieve the goal.
HTML conditionals are elaborated here https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

#1341451

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.