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
- How to add the dynamic new rows from my registration form in my database?
- Wordpress Site - pages have low text-HTML ratio
- wordpress delete unwanted location
- How to create a facet for WP gridbuilder that displays both parent and child custom fields?
- How to change woocomerce or full wordpress currency with value from USD to AUD
- error 500 on IIS FastCGI but no clue despite multiple error loggings activated
- Caching private wordpress rest endpoints
- How do i get my close button to work on a popup?
- SQL query to get student enrolled in this month in a course - Moodle
- What wordpress plugin prevent sharing of contact information amongst users?
- Password protected or private URL one-time viewable video access
- Download button not working in wordpress website. How can solve it?
- WP toolkit problem after deleting wordpress site manually
- TypeError: Failed to execute 'arrayBuffer' on 'Blob': Illegal invocation - Insert blob into database
- New Order Email Details Missing // Woocommerce / Woocommerce Bookings
Related Questions in PLUGINS
- Chrome/Firefox plug-in for automatically opening the dev tools and executing code in the console
- Creating a modal window in product edit page in Shopware6 and saving data to custom table(repository) from a form within the modal window
- Swiper.js moves slides outside of viewport/page
- Responsive Lightbox & Gallery issue
- Unity - How to add C++ file directly to be used as a Plug-in
- Can not switch camera while recording with camera plugin, setDescription working but preview doesn't change
- can anyone help me for NSIS Script I have a case where I need to check cases can be 3.3 3.42 23.5 23.56w 3.467 999.999 999.99a but not 1.b or 8..a
- How can I know if a vscode intelliSense suggestion is visible?
- Loader / Spinner infinite | Filter Everything Pro
- HTML Not Rendering and Displaying as Plain Text on Frontend with Ninja Forms in WordPress
- I want to run my own interface that I coded with Python in RoboDK
- How to redirect uploads from customers to go into specific folder?
- TestNG update related issue
- Co Author Plus: Need to add co authors names with link
- JS-issue "undefined query" when trying to create chrome-plugin
Related Questions in WORDPRESS-THEMING
- wordpress delete unwanted location
- What wordpress plugin prevent sharing of contact information amongst users?
- how to make a porfolio carousil like this in wordpress?
- Woocommerce place order in the product page
- How to fix the error, that is caused by updating elementor?
- Location of the current theme json file for WordPress Site Editor so I can add custom font?
- If and Else in single.php for showcasing multiple categories
- WordPress site not translating after adding .mo and .po files to the theme's lang directory
- How do you change the appearance of a set theme in wordpress? How do you edit the code of the theme to change asterick to a different image?
- Wordpress 6.4 Lock editing on all template files
- White space on the left and down of wordpress theme
- Not able to build menus in Wordpress
- Headless WP theme with NextJS
- Avada theme not appearing functions in functions.php file for woocommerce
- Custom Plugin: WordPress Frontend Edit Cannot Update
Related Questions in WORDPRESS-PLUGIN-CREATION
- Custom Elementor Widget Styling Issues: Front-End Styles Not Reflected in Elementor Editor - Assistance Needed
- How to ensure Correct Use of alt and title Attributes in WordPress by Amateurs?
- can't display php document in wordpress settings api tab
- How to target non-empty p elements in PHP?
- Custom Plugin: WordPress Frontend Edit Cannot Update
- how to get arguments from plugin shortcode?
- wp_enqueue_scripts not loading (class based plugin)
- How to make a custom Wordpress widget appear in the page/post editor and not just the global appearance settings
- Create a custom image size (Can't register my size)
- Transferring wp_post revisions to a custom table and reverting them back on edit page load
- Form not submitting correctly when adding input type file
- AJAX Operations Not Working Inside a WordPress Plugin
- Wordpress site: Page reloading (with changed get-param) calls the strange behaviour
- How do I output the contents of an arbitrary field of posts to a Wordpress column?
- How can I catch WordPress custom settings page slug has already changed?
Related Questions in REDIRECTION-WORDPRESS-PLUGIN
- Wordpress Plugin "Contact Form 7 to Any API"
- wordpress woocommerce within products filtering taxonomy by another taxonomy
- How to substitute part of a web path name via regex in order redirect it?
- Terawallet(woo-wallet) Button customization
- ip controller wordpress plugin
- How to populate the Content column in the wp_bp_activity table in the BuddyPress database using Gravity
- How can I redirect to the previous page after login in the Ultimate Membership Pro plugin on wordpress?
- Get page id for redirections - Wordpress
- Wp Ajax search lite add custom database table
- How to redirect dynamic URL back to source URL in WordPress
- contact form 7, I get redirected to the 404 page
- WordPress Plugin Development: How to Create an API Call without Auth
- How to get access for specific plugin for Author role in Wordpress?
- I'm unable to view my pages made in WordPress rather than home page how do I solve it?
- Translate wordpress posts ( except <code> lines )
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