Multisite Pull Recent Image Attachments from Blog ID

Use switch_to_blog to switch blog contexts to a specific blog ID. From there on it’s all down to get_posts of the attachment type. And switching back to the current context with restore_current_blog. Something like this: switch_to_blog( $blog_id ); $args = array( ‘post_type’ => ‘attachment’, ‘numberposts’ => 5, ‘orderby’ => ‘post_date’, ‘order’=> ‘ASC’ ); foreach ( … Read more

Get Permalink of Network Blog Post

That sounds pretty simple. Use: http://codex.wordpress.org/Function_Reference/switch_to_blog To go back use: restore_current_blog(); This allows you to switch from site to site. Then: http://codex.wordpress.org/Function_Reference/get_permalink My assumptions are that you have both the Blog ID and the Post ID. If that’s the case – using those two functions should solve your problem.

How can i get the last post from wp multisite?

The orderby-parameter should be post_date instead of date. your code would look something like this: $blogs = get_last_updated(‘ ‘, 0, 1); foreach ($blogs AS $blog) { switch_to_blog($blog[“blog_id”]); $args = array( ‘orderby’ => ‘post_date’, ‘order’ => ‘DESC’, ‘numberposts’ => 1, ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘suppress_filters’ => true ); $lastposts = get_posts( $args ); foreach($lastposts … Read more

How to get blog id from permalink?

the plugin “WDS Multisite Aggregate” store the blog identifier in a meta of the cloned post. then in the template file wich display the cloned posts, you can retrieve the home url of the original website with that : $blogid = $GLOBALS[“post”]->blogid; $blog_details = get_blog_details($blogid); // the home URL is in $blog_details->home I hope this … Read more

get_current_blog_id returns 1 in multisite setting

get_current_blog_id() uses the global variable $blog_id as noted at https://codex.wordpress.org/Function_Reference/get_current_blog_id. When I’ve seen this problem before it’s because I’m declaring $blog_id in my PHP code which is overwriting the WordPress global variable that provides the ID of the subsite. Change the variable name of $blog_id and hopefully the function will start returning the correct site … Read more

How to get current site id? (WPMU)

You’re right, get_current_site()->blog_id will return 1, as it refers to the network. To get the current site (blog) ID you can go like this: <?php echo get_current_blog_id(); ?> Moreover you can get the current site (blog) details like this: <?php var_dump(get_blog_details()->blog_id); ?>