What I would do is to use switch_to_blog function just before posts queries are run on the database, and then restore the current blog just after the query.
I assume that the blog where your content is is the main one (1). Just put the following lines in your second blog theme’s function.php
:
add_action('pre_get_posts', 'user16975_get_content_from_other_blog');
function user16975_get_content_from_other_blog(){
switch_to_blog(1);
}
add_filter('the_posts', 'user16975_restore_initial_blog');
function user16975_restore_initial_blog($posts){
restore_current_blog();
return $posts;
}
This should work for both back- and front-ends.
Be careful to test this fully before using, because it could have unintended behaviors. For example, all the settings used for the second blog are taken from the second blog database, so they might be different from the main blog.
Related Posts:
- Theme Activation, Create Database Tables
- WordPress Backup
- I want to run different WordPress websites under the same database
- Delete database tables on theme uninstall?
- Should a child theme share the same theme options row as the parent, or should it have it’s own options row?
- Are theme .php files stored in the database?
- Posts and Pages not showing on admin, but showing in theme
- 1 Database for multiple WordPress themes
- How to transform a custom made static HTML website to a WordPress website [closed]
- Using the same database on another Subdomain
- different theme in one website
- I’ve got a theme I can’t update and won’t let go
- Trying to revive an old wordpress site, but newer versions of wordpress install a different db structure
- Switching among theme customizations
- The function is deprecated; use mysql_real_escape_string() instead
- Uploaded WordPress theme not finding pages and css
- WordPress Theme Migration Local to Live Assets Not Loading
- How to change images size after theme modification?
- How to change database entries due to theme change
- Change information (phone number) in header of WordPress site using Veda theme
- How to change background color in the Notepad++ text editor?
- How to change or add theme to Android Studio?
- WordPress frameworks and parent themes [closed]
- Opinions and recommendations on the best barebones base theme [closed]
- Remove JSON API links in header html
- Using OOP in themes
- Where can I download WordPress themes from? [closed]
- How can I allow the Editor Role to change Theme Settings?
- What are all the available parameters for query_posts?
- Customizing a WordPress theme without changing it?
- Where can I learn to create my own theme?
- How do I turn off self-closing tags for markup in WordPress (for HTML5, or HTML4, for example)?
- how to add version of style.css in wordpress
- Does WordPress work without a theme?
- What is the role and history of the $content_width global variable?
- Adding admin-ajax.php to the frontend. Good or bad idea?
- How to move the sidebar in TwentyFifteen to the right?
- How to Link External jQuery/Javascript files with WordPress
- Installation failed: Download failed. No working transports found
- What is theme-compat?
- Override parent theme translation on child theme
- WordPress Theme activation hook?
- Can wordpress theme folder name be changed freely and nothing technically happens
- Link to specific Customizer section
- What does exactly GPL license mean for my WordPress theme?
- Am I allowed to license my WordPress theme under the aGPL
- How do I change the header image height in Twenty Seventeen?
- Starter Theme vs Parent Theme? Pros and cons
- How to change the language for the front-end only?
- W3 Total Cache, CDN and theme files [closed]
- Best way to include Bootstrap in WordPress
- How to set thumbnail image for a (child) theme
- Different template of products for specific category. WooCommerce
- Show different theme for admin?
- How can I version the main CSS file?
- what the best way to include images from the template’s images folder?
- Is it OK to remove theme credits from footer? [duplicate]
- Undefined offset: 0 in > […] /wp-includes/capabilities.php on line 1067
- How can I get the title attribute from get_the_post_thumbnail()?
- Dash or underscore in theme folder name?
- No “Add New” Button. How to add new theme?
- How do I add support to my theme for custom menus?
- “Unexpected error” on update requests
- How to prevent plugin, theme installation failures on WordPress?
- How do I white label my self-hosted site created by wordpress?
- Do Child-Themes automatically load the Translation from the Parent-Theme?
- When cropping a header image, retain meta data (i.e. name, description, etc.) from original image?
- Best practices for a Style/CSS based theme options page?
- How to create a new theme from scratch?
- Categorising themes by folders in backend
- Switching themes without losing widgets?
- How to use media upload on theme option page?
- Dynamic template serving, change theme_root using add_filter from current theme
- What theme is good for posting code? [closed]
- WordPress 5 / Gutenberg – theme doesn’t have featured image option showing up
- Custom Taxonomy-specific JavaScript
- How to refresh WordPress Customizer panel upon entering a value
- Set Featured Image for Archive templates
- is_front_page only works in theme file, and does not work in functions.php
- What is meant by __(‘page’,’twentytwelve’)
- How do I add a new string to a .po or .pot file?
- Adding Language Support using .pot and .mo files to a WordPress Theme?
- Difference between stylesheet_directory and template_directory
- Free/Open-Source Theme Frameworks as an Alternate to Thesis? [closed]
- can require “themefolder/includes/widgets.php” in “themefolder/functions.php” yet widgets.php doesn’t run
- Using Multiple Themes in a Single WordPress Site?
- Adding a Template to the Page Attributes Panel for both Posts and Pages?
- How to override the “inc” folder (or any folder) in a theme using child theme?
- How to license my commercial WordPress theme? [closed]
- How to Use WordPress as Static CMS Without Blog Posts
- Any official way to create an admin theme?
- Pre-populating the Page/Post Content Editor with HTML Snippets?
- How do I create my own admin button and theme settings page?
- Is it possible to access Gutenbergs reusable blocks in CPT block templates?
- How do you change the theme location?
- Splitting an Evolving Site into Multiple Sites, or Maintaining as One Site?
- Two instances of WordPress with different URLs and themes
- Is “Featured Content” in Twenty Fourteen done with a plugin, or is it native in WP4.0?
- Looking for a way to load a function after customizer preview refresh complete
- Multiple image logo for theme