The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

How to get all posts (custom types) from all sites (2 posts)

  1. JacoboPolavieja
    Posted 5 years ago #

    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?


  2. JacoboPolavieja
    Posted 5 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic