[wp-hackers] showposts/posts_per_page bug?

Peter Westwood peter.westwood at ftwr.co.uk
Mon Dec 20 08:38:49 UTC 2010


On 19 Dec 2010, at 22:49, Jeremy Clarke wrote:

> FWIW you guys should avoid get_posts() either way, it's a loser function and
> I don't know any use-cases where you aren't better off fetching the full
> WP_Query object instead by doing:
> 
> $myresults = new WP_Query($args);
> 
> That way you can do $myresults->have_posts() and friends. It's also almost
> definitely less buggy than get_posts() because core developers probably
> never use get_posts(). Glad to see the bug with fixed though :)
> 

We use it a little actually:

./wp-admin/includes/nav-menu.php:				$search_results = get_posts( array( 's' => $searched, 'post_type' => $post_type_name, 'fields' => 'all', 'order' => 'DESC', ) );
./wp-includes/class-wp-xmlrpc-server.php:		$pages = get_posts( array('post_type' => 'page', 'post_status' => 'any', 'numberposts' => $num_pages) );
./wp-includes/class-wp-xmlrpc-server.php:		$attachments = get_posts( array('post_type' => 'attachment', 'post_parent' => $parent_id, 'offset' => $offset, 'numberposts' => $number, 'post_mime_type' => $mime_type ) );
./wp-includes/post.php:	$children = get_posts( $r );
./wp-includes/post.php:	$results = get_posts( $r );
./wp-includes/nav-menu.php:	$items = get_posts( $args );
./wp-includes/media.php:		$_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );

;-)
-- 
Peter Westwood
http://blog.ftwr.co.uk | http://westi.wordpress.com
C53C F8FC 8796 8508 88D6 C950 54F4 5DCD A834 01C5



More information about the wp-hackers mailing list