[wp-edu] Plugin to group posts across a subset of sites?
Jonathan Cox
jcox9 at vcu.edu
Fri Sep 28 12:50:26 UTC 2012
Check out http://codex.wordpress.org/Function_Reference/switch_to_blog and http://codex.wordpress.org/Class_Reference/WP_Query#Tag_Parameters
I'd do something like
foreach ( $blog_ids as $blog ) :
switch_to_blog( $blog );
$the_query = new WP_Query( 'tag=whatever-tag' );
while ( $the_query->have_posts() ) :
$the_query->the_post();
sprintf( '<h1><a href="%s">%s</a></h1>', get_permalink(), get_the_title() );
// more the_loop stuff here if you want
endwhile;
endforeach;
The initial blog would need to be restored after the foreach block, but I can't say offhand if restore_current_blog() will restore it or the penultimate blog.
It obviously becomes less efficient the more blogs you switch to and the more posts you pull.
Jonathan Cox
VCU Webmaster
Technology Services
(804) 827-0067
On Sep 27, 2012, at 10:18 AM, Grogan, David wrote:
> Hello all,
>
> Does anyone have a solution for this use case?
>
> Given a subset of sites in our multi-site instance of WordPress, list the posts across those sites that have been specific tag or category.
>
> Thanks,
>
> David
>
> --------------------------------------------------------------
> David Grogan
> Senior Solutions Specialist
> Educational & Scholarly Technology Services (ESTS)
> University Information Technology (UIT) Tufts University
> 108 Bromfield Rd
> Somerville, MA 02144
>
> Phone: 617.627.2859
> Fax: 617.627.3082
>
> http://uit.tufts.edu/at/
> http://sites.tufts.edu/davidgrogan
>
>
>
>
> _______________________________________________
> wp-edu mailing list
> wp-edu at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-edu
More information about the wp-edu
mailing list