When you create a new site with multisite WP does not automatically change the context. So your action is added to the current site, not the new site. You have to switch first. Like this:
add_action ('wpmu_new_blog', 'wpse296303_delete_wordpress_defaults', 100, 1);
function wpse296303_delete_wordpress_defaults ($blog_id, $user_id, $domain, $path, $site_id, $meta) {
// Switch to the newly created blog
switch_to_blog ($blog_id);
// Delete 'Hello World!' post
wp_delete_post (1, true);
// Delete 'Sample page' page
wp_delete_post (2, true);
// Delete 'Sample comment' page
wp_delete_comment (1, true)
}
I’m not sure if the ID of the default comment is 1, so you’d have to check that.
Related Posts:
- Can we use one WordPress installation for multiple databases, domains and content directories
- .maintenance and maintenance.php also in multisite install?
- global menus made from master site’s custom menus wpmu network
- Can You Export Theme Settings From WordPress Multisite?
- WordPress Multi Site Best Practice
- How to run a test WordPressMu to WordPress3 update?
- Suggestions for WPMU Migration (advanced)
- WordPress Network Feature
- Multi-Site Plugin Activated (Not Network-Activated), What Happens?
- Custom column under All Users (multisite network admin)?
- Syncing Avatars across multisite
- Why would switch_to_blog stop working?
- Override database config for WordPress multiblog
- How to insert a sitemap within a subsite when using WordPress multisite
- Add custom user profile field to default WordPress MultiSite registration form
- Turn off redirect to canonical domain (or host website on any hostname)
- What changes we need to make to a theme so it can be installed as a MU Theme?
- Multi Site installation inside a sub domain inside a sub directory
- Showcase elementor templates
- Create custom dashboard for Multisite admins
- One WordPress Installation for 2 Domains
- How can I create a second multisite network in a subdirectory?
- Manage multiple domains from one backend
- Static admin page for all multisite users
- One WordPress install for main site at domain.com and blog at blog.domain.com?
- What is the best way to move a single site from one MS installation to another? [duplicate]
- Multi-site User Sessions
- What happens to the mu-plugins folder when you upgrade to WordPress 3?
- In WordPress 3.x, I can’t access posts from all blogs in the network
- I w’d like to know If there are simple solutions to integrate other CMSs to wordpress
- Add the site’s name as prefix when adding new users? Multisite
- Open “Visit site” in a new window?
- Allow multisite admins only to create users with one specific user role?
- How to have multiple WordPress Menus
- Create new network instance, import old single installs AND keep the urls?
- How to do multi site setup
- How can I resolve a .htaccess internal server error setting up a WordPress multisite?
- how or where wordress collect unlogged user session
- Global theme customization multisite
- Multisite with subdirectories, and a WordPress installation in a custom folder
- website is not loading home page (moving from one server to another server)
- Is MultiSite the Correct Solution for a Corporate Site with Searchable Regions?
- How should I design subcategory login site?
- How to have differents sites share the same tables of DB?
- Add button to My Sites dashboard page (multisite)?
- Create page when a new site in multisite network is created?
- Get site ID from attachment url?
- Multi-site customization
- How to delete post revisions?
- How do register_sidebar() and get_sidebar() work together?
- Custom category order with get_categories
- Editing theme files and access to the Code pages only to super-admin?
- Pagination Help on Crazy Custom Authors Page
- Getting rid of the #038; when string replacing content
- Querying multiple WordPress custom fields with AND qualifier
- WordPress custom post types breaks permalink on theme reinstall
- Create a Custom menu item fetched by Product Categories and Sub Categories
- How to get last_updated and newest_blogs in WP 3.0
- Adding action to save_post, post needs to be saved twice for function to work
- 1 bit audio player
- Outputting posts from post id´s in variable
- Theme licensing and permission on changing content [closed]
- Add ‘Creator’ User Meta when adding user
- Auto login after wordpress installation
- Determining What Content Gets Displayed
- Truncating varying lengths of information
- How to get pages id in array in get_pages?
- Access post meta in future_to_publish function
- Javascript Solution Remove Specific Tag but leave the rest in a specific DIV
- woocommerce_checkout_fields modifying existing billing_phone label created new field
- custom meta box for page default template
- How to host 2 subdomains as lookalike destinations under one master domain?
- “An automated WordPress update has failed to complete – please attempt the update again now”– But there is no .maintenance file
- Custom Login Process
- How could I verify whole WP directory before/after working with a freelancer? [closed]
- Modify files without losing customization after updates
- Is it possible to make wordpress LMS
- Different Domains in Multisite Setup
- Custom Content Page
- How to add functionality to an existing theme (using child themes)
- URL and Site title outputting on Login page
- How do I make mysite.com/comingsoon WordPress to become my main website’s WordPress?
- Customize section does not show my widget areas
- Invitation link to a site in multisite network does not work?
- Lightbox not showing image caption
- WordPress core jquery version file not loaded?
- Can we add an extra button on woocommerce shop page and use it to send the product info including image in a mail?
- WP_User_Query Search Multiple Keywords from a Multi-Select Field?
- clickable toggle menu, help
- How to append the excerpt to the content in the single post page?
- How to Password Protect whole site except for some subdirectories
- Ordering a specific post type
- Header image doesn’t show up on page
- Assign classes to Custom fields
- Create a Network of Different websites with wordpress
- Custom WordPress SQL Query 4 posts per custom taxonomy
- Prevent posts from being published if the ‘Uncategorized’-category or no category is selected
- Disable all Fonts that are Standard in WordPress and replacing them with a custom Font?
- Custom product sorting archive page
- Add custom information in editor summary