This is how I do it. You may want to reset and call it as a function in case you want to reuse.
// Most Recent
function nt_mostrecent( $count ) {
$my_query = new WP_Query( array(showposts => $count, order => 'DSC', orderby => 'date'));
while ($my_query->have_posts()) : $my_query->the_post();
$posts .= '<a href="' . get_permalink() . '">' . get_the_title() . '</a>';
endwhile;
return $posts;
wp_reset_query();
}
Related Posts:
- How can I export WordPress posts’ attachments?
- How can I export and then import posts with featured images?
- Exporting Data from WordPress into a flat table
- Importing New Posts from Live Site into Local Dev Site
- Export posts manually selected by end user (not logged in)
- How much of my site can I recover from public_html?
- Get ALL post ID’s export list (Only id’s. Php or sql not important )
- WordPress Local And Live Site
- Overwrite posts/pages via import
- Importing posts only – consequences?
- Extract wordpress posts content and category content
- When moving a WordPress installation to a new server, why do I have to update each post before content shows?
- Featured image error after importing blog posts
- Moving Posts to a new site and maintaining URLs
- Export Posts Without Categories In An XML File
- Turn a URL into an Attachment / Post ID
- Is it possible to Schedule Attachments in WordPress?
- Allow variable amount of comments before pagination
- How to get the number of posts in a selected category?
- Check if post has children or not
- Attach pdf file to custom post type
- Create custom page in WooCommerce
- Duplicate posts
- HTML code in Custom field
- Count singular post views automatically
- Looping through posts per category gives same posts for each category
- how to hide specific post from google search
- Accessing $post variable from template part
- get_terms parent for current product only
- post_parent is 0 when uploading new files
- Redirection to taxonomy posts list after post submit.
- Frontend Post Excerpt field mapping
- Divide Loop Into Days & Categories
- How to get future ID for post which haven’t been created yet?
- WordPress – Hide posts in admin from user who did not write them
- How to pull blogposts using shortcodes
- How to display different number of posts
- What part of template to edit to remove category name from the top of posts?
- Register post status, exclude from searches
- how to get posts ids inside pre_get_posts filter?
- Ajax Dynamic Archives not showing correct results
- Load post attached images on a single page site with fancybox
- How to allow logged in users to post anonymously
- use wpml_post_language_details function other plugin based on $post->ID [closed]
- Custom Post Type – Category Rewrite – Remove Rewrite from Sitemap
- Non-existant URL redirects to existant one
- How to Next and Prevous Navigation Buttons on the end of the page with custom image Using Wp Post Navigation Plugin
- Custom Posts Query and meta_query Sort Order
- Exclude the first ‘n’ number of posts of a tag from home page?
- how to show single post in a custom template
- limit to months rather than by number of posts
- What do comments with […] mean?
- How to add category post count in main navigation menu [closed]
- Remove current category from post but display all others
- How to get links to the last N posts in a specific category?
- wp_update_post question on array
- Is there any way to tell when wp_postmeta has been updated?
- Why won’t pagination work?
- Single post page breaks when post is more than 30,000 words
- Front end post submission form with duplicate type fields
- How do I include the category next to the title of a post?
- Posts and Pages: 404 Page not found
- WordPress post next/prev not working
- Are post, page and category IDs unique to each other?
- Different number of posts per row in grid layout
- Author Avatar as default first image
- changing parent_id on post
- Help on conditional statement to accompany wp_insert_post function please?
- How to automatically share posts on facebook?
- Delete media from the post but keep my featured image and post
- Merge get_comments & get_posts into a single query
- Every time I try accessing a post it redirects me to the feed
- Loop and output 4 rows of posts on home page
- Bulk Post update_post_meta
- More Than 50K Categories and WordPress Admin Panel Stop Showing Categories and Posts
- Hiding the name of the user who is currently editing
- allow editor/author to publish others posts but not publish their own
- Why does media_handle_sideload upload to last month’s folder?
- Re-order Category Meta-data
- Slug collision between page, taxonomy and custom post type
- Populate a drop down list with post titles across a multisite network
- Random order of the 5 most popular posts
- List posts of assigned categories in list of all categories on single.php
- Display result of custom form
- How can I choose and change a post title at random from an array when it is published?
- How to change number of posts shown on homepage vs other pages?
- How to show the posts list into a static page? Problems to use the loop into a static page
- Displaying Results From Custom Taxonomy Query
- find posts with exactly 3/4 categories
- new blog post does not appear in blog after publishing
- wordpress taxonomy results
- Displaying only posts from a certain category on my custom page template
- How can I create a menu items from meta box based on users input
- WordPress strips some attributes for author posts
- wp trim function not working
- Custom post page has attributes of latest post [closed]
- get value from post to sidebar
- How to make “my posts” page
- How to have 2 posting pages on a blog
- How to use shortcode to get the second to newest post?