What you’re looking for is best achieved using a custom query:
$top = new WP_Query( array(
'category' => 'YOUR_CATEGORY_SLUG',
'orderby' => 'post_date',
'order' => 'DESC',
'posts_per_page' => 1
) );
if( $top->have_posts() ) {
$top->the_post();
// Do things as if we were in the loop...
}
By default, sticky posts are brought to the top of any query results.
Related Posts:
- Get the children of the parent category
- How to check if I’m on the last page of posts?
- How do I get the category URL from get_the_category?
- Default WP Gallery – show only galleries of a certain category
- WP_Query not looking at child category
- Using categories & “stickyness” together
- Display all posts in category, with specific tag posts at top
- Display list of Sub-Categories and the posts they contain, within one main Category
- Loop with Dynamic Categories
- How can I create a loop to build slides based on multiple categories using Coda Slider
- Categories list loop – add separator every year
- How would you create a “weekly” archive?
- Sticky Posts Not Sticking to Top of Category Archive
- How to exclude categories from recent posts, recent comments & category widgets?
- Listing all posts from current category on page
- Check if post belongs to any category
- How do I display the posts from a custom post type on a category.php page?
- Exclude category from loop not working
- Listing Parent, Child and GrandChild Categories and then the PostTitles on Page Template !
- Category archive page – loop through posts of certain tag (with pagination) – pre_get_posts
- If newest post of category is newest post in general, skip first post of category
- Why would in_category only return one post in a specific category?
- Stick multiple posts in a single category
- Redirect category to url with /category
- Second level subcategory
- how to define category loop last class in the third
- Class active for Archive link – looped out
- Taxonomy name repeating when showing 2 posts from each category
- Display the last post by each category?
- Remove product category placeholder image (Woocomerce)
- Counter in loop in foreach
- Multiple Loops on category.php with pagination on last loop
- How to exclude the last post from a category(featured for example) from the main loop?
- Order by category titles
- Sticky post for each category on category pages [duplicate]
- ajax for filtering posts by category in wordpress loops
- How to insert category list into post creation page, and retrieve chosen categories?
- Limit get_categories to show each category once
- Display single category name in woocommerce loop
- Show Posts from Single Category Not Working
- Is there a reason I cannot get the current category in a loop?
- Category archive is displaying all posts rather than the specific category
- Pagination on category.php and tag.php not working
- new WP_Query all post in a category inside the loop
- Problem with different query loops (and “main loop”) on category template page!
- How to do paging in the loop?
- How to add orderby parameter for sorting on category.php
- How to display sticky or latest published post on the current category page it belongs to?
- How to loop custom post_type from (a) specific category(ies)?
- How to display the parent category if only the child category has been chosen
- Category tags with comma’s
- Display posts of certain categories to specific user roles
- Simple way to style posts of a single category differently in the loop and in single
- Remove any product that is featured from regular display loop [WooCommerce]
- More efficient way to list posts by category [duplicate]
- Category nicename inside loop in wordpress
- Get the ID of the current post’s child category
- filter a loop base on specific category
- Problem with multiple loops in wordpress theme
- multiple values in an array for category__and does not work with WP_Query
- List post only under the category, exclude child category content
- Editing Loop So It Targets Specific Tags?
- Problem: retrieving parent category’s first post
- How to get posts using category slug in ClassiPress?
- Posts made to category don’t show up (do show up on frontpage)
- Exclude posts without category from loop
- Display all categories but only if they have posts in them that have a specific tag assigned
- How do you get sticky posts to work with categories?
- Show the number of the post
- How can I have sticky posts while ALSO showing posts from a specific category using one WP_Query?
- How to create a category loop on my blog (ACF Plugin)
- Please tell how to stop the category from showing up on posts
- Loop by category and meta_key
- Assign a class to first element in category in loop
- Displaying Category in sidebar post widget but not in the loop on home
- Category page shows only 1 post when that post has more than 1 category?
- Configure query with multiple categories in a custom order?
- How can I modify this code to iterate over an array of categories?
- Loop within category’s posts
- How to exclude a specific categogy from a custom page template
- Display one post on category.php: Wrong featured image
- Loop through posts of CatA and store value of CatB in separate array
- How to add an empty entry to masonry?
- WordPress Numeric Pagination with Query String [duplicate]
- Loops in category description
- Several loop in search result
- Printing direct descendants of a category with WP_Query
- Category slug in in loop always the same?
- 2 loops in archive.php (one for each category)
- My Query is getting the wrong data
- Detecting top parent category fails on home page
- How do i add custom post types to this query?
- Custom WordPress category page showing all posts rather than the specified category
- How do I hide posts in a category from all listings but still allow the posts to be viewed?
- How to create a custom loop ordered by Categories on a Page Template?
- Do not show all post from all categories, just show posts from category in current loop
- Echo Category In Loop
- How can I implement pagination on custom category page?
- Order Categories by Character Count
- Get categories by title descendant