I have 8-9 subsites on the main site. I would like to have at least 2-3 latest articles/posts from each of the subsite blogs on the main site home page. is there any plugin/widget that can do or is there any code that we can put in the main site theme to publish multiple posts from every single subsite
how is it possible to have multiple articles from sub-site shown on main wordpress site
181 Views Asked by deep.er At
2
There are 2 best solutions below
0
reddfox
On
You can use the switch_to_blog function in order to query posts from any site on the network. Then, you might want to do something like:
// Switch to a particular site on the network
switch_to_blog( $site_id );
// Retreive the latest 3 posts
$args = array(
'post_type' => 'post',
'posts_per_page' => 3,
'orderby' => 'date',
'order' => 'DESC'
);
$latest_articles = new WP_Query( $args );
while ( $latest_articles->have_posts() ) {
$latest_articles->the_post();
// do some stuff such as the_title(), the_content(), etc.
}
// Restore the original query
wp_reset_query();
// Get back to the original site
restore_current_blog();
Hope that helps!
Related Questions in WORDPRESS
- Ajax jQuery firing multiple time display event for the same result
- Retrieving *number* pages by page id
- How to change the name of the file during unzip?
- Pass variables to extended class
- Dynamic wordpress background Based on Slider images
- I want to remove certain parent- and child-divs in all my wordpress posts with php or some other script
- Wordpress limit post that subscriber can create
- CSS styles for all instances of a WordPress widget
- Detect the function that redirects the page
- Show success or error messages in Ajax response to Wordpress custom registration form
- Internal 500 server error: .htaccess: RewriteCond: bad flag delimiters
- Rerun loop after every third post? (Wordpress)
- Error 404 not going after Wordpress Permalink change to custom structure
- YouTube views not counting on Wordpress embed
- Include only specific categories in WooCommerce product categories widget
Related Questions in PLUGINS
- How to specify SonarQube rule description as a markdown/html resource file instead of using annotation?
- JENKINS Maven Build Failure
- disable update for wordpress plugin named Dropbox Folder Share
- Fancytree: implementing bootstrap skin
- Send information to Maya node instance in cpp
- Which plugin is used to show the data in front end of socrata
- Reuse jquery plugin without conflict
- how can i use require(""); in javascript
- Phonegap VideoPlayer Plugin Sample Code
- How to resolve java.lang.StringIndexOutOfBoundsException: String index out of range: -325 while deploying Liferay Ext plugin 6.1
- Wordpress plugin: How to depend on other plugins?
- Notification.alert not working cordova version 4+
- FindBugs in Intellij - Possible to reuse .fbpref file?
- ACF Gallery thumbnails (image included)
- Cordova plugin development - adding aar
Related Questions in WORDPRESS-THEMING
- How to change the name of the file during unzip?
- Alignment issues with Woocommerce Checkout
- Adding custom css to default style.css (Underscores _S Wordpress theme)?
- Wordpress Custom Post Type Search
- Responsive WordPress Themes
- TinyMCE editor in WordPress is not loading correctly
- wordpress wp_enqueque not working
- Wordpress Fallback image
- custom WordPress tag.php page .. trying to get tag info
- get_posts - orderby desc wrong order
- how to add a logo on custom wordpress theme
- Can I set wordpress theme via code
- jQuery implementation - not all scripts work well
- Wordpress add custom page without adding template
- How to remove woocommerce tab?
Related Questions in WORDPRESS-PLUGIN-CREATION
- Wordpress plugin approval standards: ## Calling file locations poorly
- File upload URL
- Registering a Wordpress REST route and endpoint for a function stored in a custom plugin - how to point to the existing plugin function and path
- Failed to send email in wordpress custom plugin with SMTP plugin configured
- Where to register REST route to wordpress plugin endpoint
- wordpress attach scripts not working properly
- Elementor: Get content from builder with in plugin
- How can i Insert another post on post save?
- Can not modify wordpress default upload directory
- Is there a way to submit form data in WordPress using WPForms (Pro) from inside another function?
- How to post client side multipart/formdata to.net core rest API using wordpress wp_remote_post?
- Wordpress plugin can't save media from external API
- How to manual update a private WordPress plugin from free to pro version
- Fatal error: Uncaught Error: Call to undefined function wp_generate_password() or wp_mail()
- Greenhouse job board integration on wordpress website
Related Questions in REDIRECTION-WORDPRESS-PLUGIN
- How to substitute part of a web path name via regex in order redirect it?
- wordpress woocommerce within products filtering taxonomy by another taxonomy
- Redirection from after slash word to query
- Regex to redirect all traffic to new path except ending with specified string
- how is it possible to have multiple articles from sub-site shown on main wordpress site
- How can I redirect to the previous page after login in the Ultimate Membership Pro plugin on wordpress?
- Wordpress/Redirection plugin - how to redirect migrated blogger=>Wordpress.com `?m=1` links?
- I'm unable to view my pages made in WordPress rather than home page how do I solve it?
- How to get access for specific plugin for Author role in Wordpress?
- Translate wordpress posts ( except <code> lines )
- contact form 7, I get redirected to the 404 page
- How to redirect dynamic URL back to source URL in WordPress
- Get page id for redirections - Wordpress
- Wp Ajax search lite add custom database table
- How do I speed up a WordPress website in terms of SEO?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
thank you @redfox however i used plugin network extended. that made it easier by using the shortcode and it helped to increase posts from every sub site to display on main site.
thank you