Support » Fixing WordPress » How to get all posts (custom types) from all sites

  • JacoboPolavieja


    Hello all,

    I’m building a project where I have several custom post types and taxonomies in the main blog and on the “child” sites/blogs.

    I need to show the last 50 “posts” whatever type they are in whatever site they’ve been published.

    I’ve look for plugins, although I’d prefer to code the thing myself. I got to MU-Helpers, which has the function:

    function get_all_blog_posts( $num_per_blog = 1, $orderby = 'date', $sort = 'post_date_gmt' )
    	$posts = array();
    	$blogs = get_blog_list( 0,'all' );
    	foreach ( $blogs as $blog ):
    			$posts = array_merge( $posts, get_posts('orderby='.$orderby.'&numberposts='.$num_per_blog) );
    	return _quicksort( $posts, $sort );

    But I guess the “get_posts” function just retrieves the “post” post types, not the custom ones.

    Any idea how to achieve this?


Viewing 1 replies (of 1 total)
  • JacoboPolavieja


    Sorry… re-reading (I don’t know how I missed it the first time) the Codex for get_posts I see it accepts $post_type argument which can do, in principle, what I’m looking for.

    I’ll try it out and answer back.

Viewing 1 replies (of 1 total)
  • The topic ‘How to get all posts (custom types) from all sites’ is closed to new replies.