[wp-hackers] Method to retrieve all posts/pages from a blog

Otto otto at ottodestruct.com
Tue Apr 8 17:35:33 GMT 2008


Did you try:
$allposts = get_posts(array(numberposts' => 0, 'post_type' => ''));

Looks like it should work.


On Tue, Apr 8, 2008 at 9:58 AM, Volkmar Seifert <vs at nifelheim.info> wrote:
> Hello all,
>
>  according the the coding-standards, one should better not attempt a direct
>  retrieval of data from the wordpress-database. With this in mind, I went
>  in search for a method retrieving all posts and pages of a blog. I found
>  get_posts(), but this method does not return a) only posts, no pages, and
>  b) not all either. The same applies for the pages.
>  In interest of compatibility, abstraction, and minimization of
>  database-requests, I would prefer a single method retrieving both, pages
>  and posts, of a blog - and -all-, not just a certain number, as
>  get_posts() does.
>
>  A bit of research showed me, as I wrote before, that such functionality
>  does not exist, yet. I think it would be wise to implement such a feature,
>  as for example the sitemap-plugins could stop attempting to harass the
>  database themselves. Instead they could use the appropriate function, and
>  with this stop the need to care about compatibility with future versions.
>  (In fact, the work on my own sitemap-plugin for wpmu lead me to this issue
>  ;) ).
>
>  - Volkmar
>
>  --
>  http://blog.nifelheim.info/tech
>  _______________________________________________
>  wp-hackers mailing list
>  wp-hackers at lists.automattic.com
>  http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list