Multisite switch to blog

If you use switch_to_blog, that use always also restore_current_blog. The restore_current_blog function undos the last call to switch_to_blog, but only by one step, the calls are not nestable, so always call restore_current_blog before calling switch_to_blog again.

Sort posts according to date

Here’s how I’d attack your problem (in fact I think I’ve written code like this in the past, but I can’t find it at the moment): $blogs = array( 4, 1 ); $all_posts = array(); foreach( $blogs as $blog ) { switch_to_blog( $blog ); $args = array( ‘posts_per_page’ => 10, ‘orderby’ => ‘date’, ‘order’ => … Read more

Include Site 1 Posts in Query for Sub Sites

If you want to work with it just like with WP_Query, you can use this construction. $query = new Network_Query( array( ‘blog_id’ => array( 1, get_current_blog_id() ), ‘posts_per_page’ => 5, ‘date_query’ => array( ‘after’ => date(‘Y-m-d’, strtotime(‘-1130 days’)) ), ‘meta_query’ => array( array( ‘key’ => ‘shows’, ‘value’ => $id, ‘compare’ => ‘LIKE’, ) ) ) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)