wp_get_recent_posts [ WordPress Function ]
wp_get_recent_posts ( $args = array(), $output = ARRAY_A )
| Parameters: |
|
| Uses: | |
| Returns: |
|
| Defined at: |
|
Similar Functions: wp_get_comment_status, wp_count_posts, get_adjacent_post, wp_set_comment_status, wp_get_single_post
Retrieve number of recent posts.
Source
<?php
function wp_get_recent_posts( $args = array(), $output = ARRAY_A ) {
if ( is_numeric( $args ) ) {
_deprecated_argument( __FUNCTION__, '3.1', __( 'Passing an integer number of posts is deprecated. Pass an array of arguments instead.' ) );
$args = array( 'numberposts' => absint( $args ) );
}
// Set default arguments
$defaults = array(
'numberposts' => 10, 'offset' => 0,
'category' => 0, 'orderby' => 'post_date',
'order' => 'DESC', 'include' => '',
'exclude' => '', 'meta_key' => '',
'meta_value' =>'', 'post_type' => 'post', 'post_status' => 'draft, publish, future, pending, private',
'suppress_filters' => true
);
$r = wp_parse_args( $args, $defaults );
$results = get_posts( $r );
// Backward compatibility. Prior to 3.1 expected posts to be returned in array
if ( ARRAY_A == $output ){
foreach( $results as $key => $result ) {
$results[$key] = get_object_vars( $result );
}
return $results ? $results : array();
}
return $results ? $results : false;
}
?>
Examples [ wp-snippets.com ]
Top Google Search Results
- Function Reference/wp get recent posts « WordPress Codex
Description. Retrieve the recent posts. Usage. <?php wp_get_recent_posts( $ args ) ?> Default Usage. <?php $args = array( 'numberposts' => 10, 'offset' => 0, ...
codex.wordpress.org - displaying date and excerpt with wp_get_recent_posts ? - WordPress
I'm using the wp_get_recent_posts to add a custom recent posts thing to my child theme. I've got the ... Is this even possible with wp_get_recent_posts?
wordpress.org - php - Using wp_get_recent_posts - Stack Overflow
I am writing my own theme, and in the sidebar I want to list details on ... Might not be easy, as the function reference doesn't show any tag ...
stackoverflow.com - Show ONLY WP Recent Published Posts | ElegantWebDesigns ...
Jun 28, 2010 ... <?php wp_get_recent_posts( $num ) ?> By default $num will pull the 10 most recent posts, but you can add any number you want. Now this ...
www.elegantwebdesigns.net
User discussions [ wordpress.org ]
- marenm on "displaying date and excerpt with wp_get_recent_posts ?"
- fishfinder on "displaying date and excerpt with wp_get_recent_posts ?"
- marenm on "displaying date and excerpt with wp_get_recent_posts ?"
- Escort-Italia on "Checking if a specific post is a draft? after wp_get_recent_posts();"
- MaFt on "Checking if a specific post is a draft? after wp_get_recent_posts();"
- saiberfun on "Checking if a specific post is a draft? after wp_get_recent_posts();"
- saiberfun on "Checking if a specific post is a draft? after wp_get_recent_posts();"
- skunkbad on "permalink for my list of recent posts"
- MichaelH on "Why would wp_get_recent_posts() return nothing?"
- DigitalFormula on "Why would wp_get_recent_posts() return nothing?"