How to get all posts (custom types) from all sites
-
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 ): switch_to_blog($blog['blog_id']); $posts = array_merge( $posts, get_posts('orderby='.$orderby.'&numberposts='.$num_per_blog) ); restore_current_blog(); endforeach; 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?
Thanks!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘How to get all posts (custom types) from all sites’ is closed to new replies.