Setting a Default Theme for all Subsites in a WordPress Multisite
If you want all the sites on your network to use the same theme, but would rather not use the current WordPress default theme, you would have to manually switch to the preferred theme each time you created a new site.
1. Install the multisite network as given in What Is Multisite? How To Create a WordPress Multisite Network?
2. Insert code to set the default theme for subsites.
You can override the WordPress default theme by editing the wp-config.php file. Just insert the following code anywhere before the line where WordPress includes the wp-settings.php file.
define( 'WP_DEFAULT_THEME', 'your-default-theme' ); require_once(ABSPATH . 'wp-settings.php');
Note: You’ll need to replace “your-default-theme” with the name of the theme you want to set as the default across your network.
3. Now create subsite for your multisite network. It will come with the theme activated which you set as default.
Setting a Default Logo for all subsites in a WordPress Multisite
The logo can be set as the background image in the header.
If you insert the below code in style.css of the theme, this logo will be automatically displayed in all subsites when the theme is activated. However, if you do not want to make any changes in your theme, you’ll have to create a custom plugin and add the code there. Be sure to network enable the plugin so that the changes are applied to all subsites.
1. Upload the logo image on your main site. Let’s assume you’ve named it mylogo.
2. Get the absolute URL of the image, and use this in your CSS.
.header-image .site-header .site-title a { background: url(http://main.com/wp-content/uploads/2020/01/mylogo.png) no-repeat left; padding: 0; }
Note: Please refer to your selectors instead of this.
Setting a Default Menu for all subsites in a WordPress Multisite
If you want to set a default menu, this would mean you would want to have certain pages created also. This could be complicated but not impossible. Let’s consider that we have to add a homepage and a ‘Home’ link in the primary navigation menu (you can similarly add additional pages). The below code can be inserted into functions.php of the theme. If you wanted to insert the code in a custom plugin, you would have to make the plugin multisite compatible and then tweak the code and insert it.
// add a function which will be called when a new site is created add_action( 'wpmu_new_blog', 'create_menu_on_site_creation' ); function create_menu_on_site_creation( $blog_id ) { switch_to_blog( $blog_id ); $menu_name = 'Primary Menu'; $menu_exists = wp_get_nav_menu_object( 'Primary Menu' ); // If no menu is selected as the Primary menu and a menu with name 'Primary Menu’ does not exist // we have to create a Primary Menu if ( ! has_nav_menu( 'primary' ) && ! $menu_exists ) { $menu_id = wp_create_nav_menu( $menu_name ); // Add Home menu as default link in the menu wp_update_nav_menu_item( $menu_id, 0, array( 'menu-item-title' => __( 'Home' ), 'menu-item-classes' => 'home', 'menu-item-url' => home_url( '/' ), 'menu-item-status' => 'publish' ) ); // Assign menu to Primary location $locations = get_theme_mod( 'nav_menu_locations' ); $locations[ 'menu-1' ] = $menu_id; set_theme_mod( 'nav_menu_locations', $locations ); } restore_current_blog(); }
This will work for WordPress themes which have ‘menu-1’ as the Primary Menu navigation id.
This idea would work for any WordPress theme (the hooks will differ though). If you would want certain templates to be applied for pages created, this can be done as well, but this would be a better topic for another day.
In this article, we have to show Create and Used PIPE in angular
In this article, we have to show Create and Used PIPE in angular
In this article, we have to show Create and Used PIPE in angular