recent posts in wordpress multisite without rss
-
I’m currently displaying the 3 most recent posts and RSS links to 9 of my sites on multisite: I’m using a shortcode for the excellent “better rss widget” in my sidebar so its replicated across all my sites via my theme.
I know RSS is an inefficent way to do this.
I had though about using the “multisite widgets” but I’d rather hardcode the text.
I’ve heard about using the switch_to_blog() function in an article that instead proposed doing this:function umw_get_blog_posts( $blogid=1, $type='post', $parent=0 ) { global $wpdb; $wpdbobj = clone $wpdb; $wpdb->blogid = $blogid; $wpdb->set_prefix( $wpdb->base_prefix ); $query = $wpdb->prepare( "SELECT ID, post_title, post_name FROM $wpdb->posts WHERE post_status='publish' AND post_type='$type' AND post_parent=$parent" ); $wpdb = clone $wpdbobj; return $wpdb->get_results( $query, ARRAY_A ); }
From this site https://www.htmlcenter.com/blog/wordpress-multi-site-switching-blogs/
I’m wondering which of these or alternatives would be best.Also, because this sidebar is pulled by every page, should I include this in functions or as a seperate page or something to stop it having to be created every time (or won’t it need to be anyway?)
Thanks
Dallas
- The topic ‘recent posts in wordpress multisite without rss’ is closed to new replies.