Multiple Blogs, One WordPress Install, Multiple Headers
-
i’ve tried googling this to no avail… maybe i’m missing something, but i figured i’d try here.
i’ve installed wordpress and created multiple blogs using symbolic links as directed here, and everything looks great.
however, what i’d like to accomplish is to have each blog have its own header. i’m reading up on something that looks like something i’d like to do, but i’m not sure how to do this. could someone direct me in baby steps? what i’m referring to is this:
include (TEMPLATEPATH . ‘/’ . ABSPATH . ‘header.php’);
i don’t quite understand how this works, or what i’m supposed to do, but in reading someone’s post who had succeeded in doing what i wanted, i figured this code must be doing what i want, but i tried it and it didn’t work.
i’m hoping someone out there has had experience in this and will be able to help me out. thanks!
-
I don’t have experience with the header technique yet. I want to try it. I am using the same multiblogging technique you linked and it works brilliantly.
When I get around to trying the header technique I will post again with my findings.
First, I notice that the technique you listed would be for replacing the entire header.php — when actually, I only want to replace the graphic background of the header, putting a different picture at the top of each multiblog. Said graphic background is simply a JPG, and the code that displays this JPG is just 1 little line inside header.php. How about you? Have you a need to replace the whole header php, or just the jpg?
For now, I’ll point out, it might depend a little on your theme; in the Default theme (aka Kubrick) the header graphic is normally displayed by this code,
#header { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickheader.jpg") no-repeat bottom center; }
I aim to try changing that to something like,
#header { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/[[[SOME CODE I DON'T KNOW TO PUT THE ABSPATH HERE]]]/kubrickheader.jpg") no-repeat bottom center; }
If this works, I could simply create 1 subfolder for each multiblog inside the main theme’s /images/ folder. I would put a different graphic, always named kubrickheader.jpg, in each of these folders. Would that work?
Another concept would be renaming the JPG with a variable in the file-name. I don’t know if this is possible? Something like, ABSPATH-header.jpg.
Anyone know how to put a variable there?
Well that guy is way over the bleeding edge of WP hackery. This may not be the right place. But its going to be in the CSS.
It’s a surprisingly easy technique for multiblogging, Root. I had no clue what he was talking about, and I got myself 5 blogs set up in less than an hour from the time I discovered his post about the method. It’s bleeding edge but when people who want multiblog find this, it will solve a lot of peoples’ wishes. Infinitely better than WPMU, for what I wanted to do. This method has a different effect than MU.
AFIK, this forum is pretty much the only place to discuss it other than his comments section which has less CSS expert readership… we wouldn’t get the benefit of your input if we only asked on there.
Can you explain a way to put a variable in the path to a JPG?
Preferably, I want that variable to echo the same word that is the folder-name of that blog. So if the blog is in /joe/ then the graphic would be either your-theme/images/joe/header.jpg — or yourtheme/images/joe-header.jpg
That’s my approach/idea. The other approach mentioned above is same idea, but the variable is used in the call to the header.php
When I say *over the bleeding edge* I do not say I can not understand it. I just say that I do not (yet) know anything about it. ?? Are these multi blogs each calling their own CSS? Presumably they are? How do themes work? Those are the lines of enquiry to the answer to this. Thanks for the kind words.
The way *this* multiblog technique works, you get (example) 20 blogs = 20 databases (or 20 tables in 1 database) = just one wp-admin folder, one wp-content folder, on wp-includes folder.
Whatever is stored in the database is unique to each multiblog. Whatever is stored in the physical files is the same for all multiblogs.
Your selected theme is a variable stored in the database — therefore each blog can select a different theme. But all the themes must live in the 1 same wp-content/themes/ folder. Alternately — all the blogs can use the same theme. This is what we want to do.
Now you can imagine, if you change something in the default theme (example, you change something in the CSS), the change appears on all the blogs using that theme.
Anything that is from the database is specific to each multiblog. Example, each blog displays that blog’s own Blogname and Description in the header of the theme, even though they are using the same theme. Of course, this is because the theme has a variable in the code (a template tag) to display the blogname which reads from the database.
Each blog can run different plugins, because your plugin selections that are activated/deactivated are stored in the database. BUT each blog can only choose from the same set of plugins — those that are in the master blog’s wp-content/plugins/ folder.
Each blog can show different widgets.
Another interesting example is the header-color of the default (Kubrick) theme. Kubrick has its own Options panel that lets you choose different colors for the header (you can change it from the standard big blue). With 5 blogs running the default theme, each blog can choose a different header color. I assume this is because the header-color-option of the default theme is not hard-coded in the theme, but rather it is a variable established somewhere (your chosen color is saved in the database, I assume).
pixelgecko and myself, we want to use the SAME theme for all the multiblogs. Example, just pretend it’s the default theme. However, we want to change 1 thing: the header graphic should be unique for each blog. For me, I just want a different picture on each blog, instead of merely a different color (which I can already do).
Therefore I think we need to call a variable from the database, which identifies which multiblog you’re on, in the address of the header.php or the header.jpg.
What do you think?
Yes, that’s exactly what I’m trying to do. The reason I wanted to call a different header.php file instead of just a graphic file is in case I wanted to add something below the header graphic (a h1 tag with the name of the blog and a brief description, for instance).
Dgold is right – the method we used was surprisingly easy. It certainly saved me a lot of time and headache. If there was an easy way to call a variable from the database, allowing us to use different header.php files (or header images), then I will without a doubt be evangelizing this method of setting up multiple blogs with one WordPress install.
I’m still hoping that someone has a solution to our situation!
Pixel, I get what you’re saying IF you wanted to put something different from blog-to-blog in the header, such as in the h1 tag, OTHER than the blog name and brief description. If that’s really what you want, then just use the template-tags that bring up the blog’s name, and the other template tag that brings up the blog’s description — which is already used in the header of most themes. That way it is a variable that you can retype in the Admin of any of the blogs, anytime, without having to mess with the header.php code.
Thanks for the very clear exposition. This should be simple. Not that I know the answer. Its just calling up that variable in the header isnt it? My point is to encourage you. This is not a big deal. We shouldnt let it deter us. WPMU lite rocks. ?? I can see a lot of folk using this. One line of thought is to switch style.css to style.php. That gives a lot more power and flexibility where you need it.
Calling up a variable in the header sounds simple enough, but how would we do this? Is there a particular PHP code that we could use in our header.php file to call a particular header image, depending on which blog you’re in?
I was thinking of some code like this (this is probably very wrong, but you get the idea…)
if (blog_name_is_joe()) {
<div id=”joe_header”></div>
}or, preferably, use some kind of loop to go through all the blog names and insert the appropriate header image file.
Root – I appreciate the encouragement but I don’t speak the CSS language. I pretty much need someone to write a line of code that we can copy-paste.
Pixel, your latest suggestion would be called, I think, a bunch of “conditionals”. That’s another approach, but I don’t like it because it means 20 conditionals for 20 blogs, so the header starts to get big, and every blog has to load the whole header.
All – I’m still going back to my thought that we only need 1 variable in 1 line of code, and that variable calls up the blog’s folder-name or another 1-word identifier per blog (I don’t care if it does it automatically, or if I need to fill in a field one time per blog), inside the
<img src="https://example.com/wp-content/themes/ mytheme/images/***VARIABLE***-header.jpg">
Part of my reasoning for this is that I do something similar to call up mp3’s on a site. The code for that is pretty much
<a href="https://example.com/***VARIABLE***.mp3">
and for this, the Variable is called from a custom field, using the Get Custom Fields plugin. So where it says ***VARIABLE*** in my example, I just put the PHP code that pulls in a custom field for that post. It works like magic, every post has the mp3 link for the mp3 custom field value attached to that post. I’m just trying to wrap my head around the logic of how to do this in the header, instead of in a post — because posts can have custom fields associated with them, but I’m not sure of a way to get a generic site-wide custom field which is unique to each blog. Maybe I can still use Get Custom Fields to do it, I’ll try it later.I’m hoping someone else will see this and think of an easy way.
Dgold – yeah, your way seems much better. I don’t think it should be too difficult, but I can’t for the life of me figure it out! Hopefully someone will be able to help us out before too long.
I have a feeling we can do it with Custom Fields, because I found this in the Codex:
get_post_meta($post_id, $key, $single);
where $post_id tells it which post to get the custom field from. We could make the $post_id always point to the Hello World post (probably has an id of 1 or something like that), and we will make the $key something like “header-name” and then we have to type in the custom field value (such as “joe”) for each blog, on the Hello World post.
I just need to figure out how to put something like
<img src="https://example.com/wp-content/themes/ mytheme/images/***get_post_meta('1', 'header-name', 'true');***-header.jpg">
Can someone correct that code and make it proper PHP? It’s the part inside the *** and *** that I don’t know how to write it where PHP can run inside the img src HTML.
From my standpoint this issue is being clouded by the fact we are dealing with something very close to the default theme, which is completely out of left field in this regard with hard coded links to presentational items in the templates. Its not right.
I don’t think it changes the question, Root. Whether it’s in the style.css or in the header.php, you still type the path to the JPG.
That’s all I want to know, is how to put the PHP calling a custom field, inside the https:// path to the JPG, that can be used outside The Loop. Other issues about the theme can be ignored to answer this, so if you know, please tell.
If someone can just make the 1 line of code valid, then I’ll try it in whatever themes (default or otherwise) and let you know if it worked. I just don’t know where to put the <? PHP and the () and the }; and whatever else PHP wants, and I don’t know how that can be placed inside an https:// — I could spend all day trying different combinations.
Hoping someone who knows basic PHP rules will write it out for us
Try this plugin, from UrbanGiraffe:
https://urbangiraffe.com/plugins/headspace2
- The topic ‘Multiple Blogs, One WordPress Install, Multiple Headers’ is closed to new replies.