Change header.php of a specific Wordpress Multisite
-
11-04-2021 - |
Question
I wish to change to change the header.php of child theme and add <meta name="theme-color" content="#ff6600" />
into it.
However when using the editor under 'Network Admin', changes are reflected across all the wordpress multisites.
How can I access change the header.php of a specific multisite, as the editor is not available in the multisite's dashboard.
Thanks!
Solution
From what I understand you're using one theme across multiple blogs inside your network? If that's the case, you could edit the header.php
to add a bit of php logic into it to check on what blog your header is currently loaded.
To make it work, you'll need to get the ID of a blog you want to apply the change to (check for it in your network admin on a screen that lists all the blogs).
Then edit the header.php
and add something like this:
<?php
// 6 in my example is the blog ID that I want to apply the change to
if ( 6 === get_current_blog_id() ) {
echo `<meta name="theme-color" content="#ff6600" />`;
}
?>
The other way would be to create a new child theme with a header.php file that has the additional meta tag and activate it only on a particular blog.
Hope that helps!