Why don’t you use wp_query to retrieve posts. Its’s easy to include meta values in wp_query and a safe way to retrieve posts from wordpress database.
use this code to switch to the desired blog id and then after retrieving posts switch back to the original blog.
<?php
/*
for global variables, since it is being changed or updated from time to time,
please refer to Related Resources for more information
*/
global $switched;
switch_to_blog(2);
echo 'You switched from blog ' . $switched . ' to 2';
**//RUN WP_QUERY HERE**
restore_current_blog();
echo 'You switched back.';
?>
References:
Related Posts:
- How to disable a network enabled plugin for just one site?
- Plugin for editing options on multisite?
- WordPress Multisite: How to make all media library items available for every site?
- How to setup LDAP authentication with WP multisite
- Set default avatar network-wide
- wp-activate.php causing white screen of death
- Change wordpress Multisite default site from side id 1 to side id 2
- Multisite: Develop locally using production images with .htaccess
- latest 5 posts using switch_to_blog loop
- How to prevent hotlinking with htaccess in WordPress and why most common use about it doesn’t work?
- Why can’t a WordPress network (multisite) in it’s own folder use subdomains?
- restore_current_blog() vs. multiple switch_to_blog() followed by removing $GLOBALS[‘_wp_switched_stack’]
- How do I set a default theme in multisite network
- WordPress Multisite Login Access
- Switch_to_blog() outside wordpress
- Two WordPress sites sharing the same database
- Multisite use language code as subdirectory
- How to remove the Tools menu item from the WP-Admin menu
- Sub-subdomain getting redirected to main domain
- Using $wpdb Class to Pull Recent Comments Across a Network
- Default content for a new site in multi site
- Multisite – create new site with precreated pages, menu etc
- WordPress (+WPMU) Import/Export ALL settings?
- wordpress htaccess is hijacking my .mp4 files
- How to work on a live WPMS blog when domain is unresolved? [closed]
- How do you load WordPress from an external script when using MultiSite? [duplicate]
- Has WP and MU fully merged?
- Why is ‘is_multisite’ returning true when it’s a single install?
- Hook up MU site creation
- Migrate a WP website from a single-server single-domain to a multi-server multi-domain installation
- Forcing SSL Protocol for Multisite Subdomain Child Sites + cPanel Configuration
- Website DR using Multisite
- Fresh Multisite Install – Can’t Log In
- current_user_can() always returns true if user is super admin
- multisite hook for Add Existing User
- Displaying a message upon user registration
- access the plugins for each role in WordPress multisite
- How to redirect one page on the subdomain
- ReWriteRules and WordPress Multi-Sites with Sub Directories
- How can i redirect my Blog to a Subdomain?
- WordPress Multisite Redirection Issue
- Multisite user roles – capabilities not working
- WordPress: how to change URL for individual MultiSites?
- Change main site in multisite install?
- Multi-Site Subfolder User Permission Issue
- Programmatically Add Item to WP Multisite Menus
- why there is a large file named core in wpmu’s directory?
- WordPress multi-site, developing locally and syncing live changes
- wp_get_attachment_image_src on multisite
- Problem with parked domain for my mutisite
- WordPress multisite – What’s the ideal setup for development/staging/production environments?
- WordPress self hosted site asking to login again when used www
- Error : Cookies are blocked or not supported by your browser
- How To Run Multiple Multi-Site Networks On Same Box [closed]
- Changed sub-site to its own domain trigger 302 redirects for all page links
- Multisite – big hosting package or several hosting packages?
- WordPress network vs Separate installs
- 404 on page 2 multisite
- How can I append blog_id to … echo [functions-defined-constant]?
- Page Builders and WP Multisite
- WordPress Multisite Add User
- Which is the correct way to migrate content from single WP to WP multisite
- How to have one installation at blog.example.com and multiple blogs in sub folders such as blog.example.com/userA?
- Folder structure when using multiple domains with WordPress
- Multisite for main in subdirectory, subdomain and subfolders (EN/ES)
- the_content not working on one of two Multisite sites
- filter posts without images or featured image
- Handling embedded videos in excerpts
- How can I have two or more WordPress Pro (paid) themes that form a single website?
- On a multisite environment, get the subdomain value as variable
- How can ı change my logo for specific page?
- Tracing non-uniform slowdown on a multisite install with multiple domains
- After switch domain, some parts of my site still point to my old domain
- Automatic registration on main site upon user registration on Multisite
- Hook into ‘admin_url’ but only on Mysites admin bar menu
- Add file at the root of mapped domain in multisite
- Looking for most efficient way to ‘deploy’ single wordpress page to multiple external subdomains
- WordPress multisite REST API connection refused with android – redirects to home page when using IP address in Postman
- Multisite installation steps?
- Pass form inputs to page content
- How to show theme on front end before sign up for multisite
- How to connect existing subdomains to new wordpress multisite?
- WordPress Multisite with cPanel Addon Domains and SSL
- Shared upload folder in wordpress multisite with custom sub site domain pictures URL:s
- Multisites with different root directory
- New domain in multisite environment
- Domain Mapping with WPMU
- Why does this multisite redirection loop vanish when I add “www.”?
- Using www along with non-www for main domain in multisite installation
- Multisite “Skip Confirmation Email” Log Out Problem
- Disable/Remove default blog on Multisite Setup
- Page Template Dropdown – Missing In WordPress MultiSite
- How can I display all Multisite blogs where this user is administrator?
- Multisite and users being listed on network administration dashboard and not main site dashboard
- How to remove index.php from a tag or archive page URL in the root blog?
- Post migration from one site to another site in a network
- Are there any hosting companies that are already setup and configured for TLD domain mapping?
- Multisite features
- ERROR: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress
- How to enable subdomain -multisite work, when only subdirectory is only shown in network setup?