Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- global $wpdb; // Globalize the $wpdb object so you can use it
- /* Set this next variable to whatever the ID is of the sub-site
- you want to pull post(s) from */
- $sub_blog_id = 2;
- /* This next line of code will cause most WordPress functions to pull
- information from the site with an ID matching $sub_blog_id instead of
- pulling it from the current site */
- $oldblog = $wpdb->set_blog_id( $sub_blog_id );
- /* Use the get_posts() function - adding whatever parameters you
- desire - to pull information about the post(s) you want to pull
- from the sub-site */
- $sub_posts = get_posts();
- /* Loop through the posts you retrieved */
- foreach( $sub_posts as $sub_post ) {
- // Do stuff here to output your desired information
- }
- /* Tell the $wpdb object to go back to using the current site */
- $wpdb->set_blog_id( $oldblog );
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement