This is all about featuring content in WP.
Say, you got 1000’s of posts that you accumulated over the years and each has their own original ( and true ) post dates.
And now you want to feature them again.
Say in your category taxonomy, you have a branch called Featured and underneath are the sub items as follows;
Featured
Main Headline
Must See
Worth A look
Not to Miss
etc.
And in your theme, you have a zone to display these various featured posts. As an example, you have a “must see” zone that features the last 10 posts that you did and you happened to categorize it under “must see”.
The question is what do we mean here by “the last”?
The last according to the post_date, right?
What if I were to feature an article that’s from the past? How do I do that? Just selecting the “must see” is not going to help because as I add more and more items to the “must see” category, how do I display them in the order I featured them. One way to tackle this is to change the post_date I guess? But would not that mess up the archival information. I have a hard time justifying changing the original post date just for the sake of featuring things in proper order.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Use Sticky Posts.
In the Post editor find the “Publish” section.
Next to “Visibility” click on edit and then check the “Stick this post to the front page” option there.
Click save and you’re done.
In the loop, you can check if a post is_sticky().
To loop them, you can use the post__in or post_not__in keys for your query with a value of get_option( 'sticky_posts' );.
There are also some Plugins in case you don’t want to dig in code.
Other options…
…would be to assign
- a special category
- a tag
- …or a custom field.
Edit:
Combine categories/tags + sticky posts.
Fetch »all get_option( 'sticky_posts' ) with a Tag of “Featured” (or inside Category “Featured”), then: ORDER BY post_last_modified_date LIMIT 10«.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0