Community Forums › Forums › Archived Forums › General Discussion › Best practices for multisite Genesis/Child css
Tagged: custom css, multisite
- This topic has 1 reply, 2 voices, and was last updated 8 years, 8 months ago by Victor Font.
-
AuthorPosts
-
March 24, 2016 at 2:20 pm #182181mikelbylMember
I have a multisite install that features several sites using the same Child theme (News Pro), but each site must have its own custom style.css with different colors and fonts and other options activated. Only one of the sites is actually "live" at any one time (meaning I'm actually working on it and adding content every day), but the others still exist and must retain their custom look in perpetuity.
To date I have used a feature in Jetpack to accomplish what I want - it adds an "Edit CSS" function to the Appearance menu and the CSS in there overrides the CSS in style.css within the News Pro folder on the server.
However I would prefer it if each css file were on the server as a discrete file. If I were ever to disactivate Jetpack, for instance, I would lose this functionality (and all of those custom CSS files!)
So - everywhere I check suggests NOT using a "grandchild" theme. What *is* the recommended solution for this problem? I suppose I could copy the whole news-pro folder, rename each iteration of the folder and then specify each as a unique Genesis Child theme, but that seems like overkill to me. In my case that would mean replicating news-pro about a dozen times.
Thoughts?
March 26, 2016 at 6:50 am #182273Victor FontModeratorThe way most people would implement the same theme on multiple multi-site installs would be to copy the theme into a new directory, but you could also call style sheets conditionally in functions.php. In multi-site, each instance would have its own URL whether it's a subdomain or subdirectory install. That URL is retrieved with get_bloginfo( 'stylesheet_directory' ). This means you can add something like this to functions.php and it should work. I have not tested this in the NewsPro theme, but I would give it a try. The first line removes the default Genesis style sheet load.
remove_action( 'genesis_meta', 'genesis_load_stylesheet' ); add_action( 'wp_enqueue_scripts', 'vmf_conditional_stylesheet', 30); function vmf_conditional_stylesheet() { $cur_theme_dir = get_bloginfo( 'stylesheet_directory' ); $style_sheet = $cur_theme_dir; switch ($cur_theme_dir) { case "theme1": $style_sheet .= "/style-sheet1.css"; break; case "theme2": $style_sheet .= "/style-sheet2.css"; break; case "theme3": $style_sheet .= "/style-sheet3.css"; break; default: $style_sheet .= "/default-style-sheet.css"; } wp_enqueue_style( 'child-style', $style_sheet, array(), CHILD_THEME_VERSION ); }
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet? -
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.