[wp-trac] Re: [WordPress Trac] #7326: get_posts not working properly
WordPress Trac
wp-trac at lists.automattic.com
Fri Jul 18 04:28:09 GMT 2008
#7326: get_posts not working properly
---------------------+------------------------------------------------------
Reporter: wpcandy | Owner: anonymous
Type: defect | Status: new
Priority: high | Milestone: 2.6.1
Component: General | Version: 2.6
Severity: normal | Resolution:
Keywords: |
---------------------+------------------------------------------------------
Comment (by slambert):
I also had a problem and might be able to provide more details.
I had two instances of
{{{
<?php $posts = get_posts('numberposts=#&category=#'); ?>
}}}
running in a home.php template. The first instance worked, the second did
not. I tested, using:
{{{
<?php print "<!-- There are ".count($posts)." posts -->"; ?>
}}}
and 0 posts were found.
I tried using a different format:
{{{
<?php
$args = array(
'numberposts' => 6,
'category' => 9,
);
$posts = get_posts('');
?>
}}}
And no posts were found.
I replaced the code with query_posts:
{{{
<?php $posts = query_posts( "cat=9&posts_per_page=6" ); ?>
}}}
And it worked as expected returning the posts.
This changed for me upon update from 2.5 to 2.6.
I hope this information helps.
--
Ticket URL: <http://trac.wordpress.org/ticket/7326#comment:5>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list