Disclaimer: This is (most likely) not what you think! I’m not trying to integrate two wordpress blogs into a single blog or anything with the sql databases.
I’m using one wordpress installation as a cms for my website, and I’m using a second as a blog. I’m trying to more or less just get the header from the website cms wordpress installation included into the wordpress blog. I’m trying to do this so that the website navigation, which is included in the header php, is universal for the website and is easily maintained through a single cms.
I know if I don’t find an elegant solution, I can just replicate the structure of the cms website over to that of the blog, but this kind of defeats the purpose of using a cms.
I tried just replacing the header in the blog installation with a php include to the absolute address of the header in the cms theme installation, but that failed. Does anyone have any better suggestions?
Update: Here are some of the things I have tried:
I’ve tried this straight from the Integrating WordPress page:
<?php define('WP_USE_THEMES', true); require('../wp-blog-header.php'); ?>
Absolutely nothing. Completely blank page. Html is empty.
I’ve tried requiring the header.php in my theme directory:
<?php define('WP_USE_THEMES', true); require('Path-To-Theme-Header'); ?>
Warning: require() [function.require]: Unable to access Path-To-Theme-Header
Warning: require(Path-To-Theme-Header) [function.require]: failed to open stream: No such file or directory
I’ve tried the plain old php include:
<?php include('Path-To-Theme-Header'); ?>
Warning: include() [function.include]: URL file-access is disabled in the server configuration
Warning: include(Path-To-Theme-Header) [function.include]: failed to open stream: no suitable wrapper could be found
Warning: include() [function.include]: Failed opening ‘Path-To-Theme-Header’ for inclusion (include_path=’.:/usr/share/pear’)
I’ve tried this code I found somewhere along the way…
<?php define('WP_USE_THEMES', false); require('../wp-load.php'); query_posts('showposts=1'); ?> <?php while (have_posts()): the_post(); ?> <?php endwhile; ?> <?php while (have_posts()): the_post(); ?> <h2><?php the_title(); ?></h2> <?php the_excerpt(); ?> <p><a href="<?php the_permalink(); ?>">Read more...</a></p> <?php endwhile; ?>
Showing the default post of my blog twice. Not the post from my cms website, which it should be able to grab.
I’ve tried using the code in the example from this tutorial
Which results in:
Warning: mysql_connect() [function.mysql-connect]: Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)
In case anyone was wondering and couldn’t tell from the above, my website has the wordpress cms at the base url, and the blog at mysite.com/blog.
I feel like I’m just hitting my head against the wall here. Can anyone offer some useful suggestions? Would integrating both wordpresses into one sql database make a difference perhaps? Since the one attempt that did result in a page, just seemed to be accessing the wrong database.
I’m using one wordpress installation as a cms for my website, and I’m using a second as a blog.
I’m trying to more or less just get the header from the website cms wordpress installation included into the wordpress blog.
You can just use the one installation for the CMS and blog, and it’ll all use the same theme. There’s really no need for *two*.
I’m trying to do this so that the website navigation, which is included in the header php, is universal for the website and is easily maintained through a single cms.
Again, can be done with a single installation.
I haven’t read the rest of your attempts, because it’s really unclear as to why you’re doing it this way. You can use WP as the CMS for the site *and* have it run the blog all at the same time – there’s no problem with doing this at all (I should know, I do it all the time!)
I’m doing it this way because I wanted to have a cms for my website in general in addition to my blog. I don’t want pages, and subpages (posts, categories, and actual pages) from my website showing up as links to blog articles.
I think we’re having some sort of communication issue here, because I still don’t understand (sorry!)
You can run WordPress as a CMS just fine. You can also run it as a blog – in the same installation, at the same time. I don’t know of anything that would allow you to run a single set of theme files from one installation on another – and really I wouldn’t want to anyway because it would open up a ton of headaches. Truly, you are making *way* more work for yourself than you need to, and making things a lot harder than they should be.
You don’t *have* to have blog stuff show up on the “CMS side” – and you can keep “CMS stuff” from appearing on the “blog side”. That’s not an issue at all. if you want to have the blog match the CMS, and only edit in one spot, then you only need a single installation and use WordPress properly instead of trying to rewrite it.
Just use the static Pages for your static pages (that’s what they are for), and use the categories for the “blog” section. You can even intersperse these and have the areas seem separated. it’ll make it a LOT easier on yourself if you just take WP as it is, and use it how you like, and make those divisions within your theme editing. It’s *really* easy to do, actually.
Alright, so one of my “static” pages, actually points to a category so I can dynamically add extra posts to that static page as needed and have them formatted nicely for me. How would I exclude this category from the blog nav-bar, while keeping all the blog-related categories?
I have a feeling you’re going to mention some way to exclude pages and categories from the navbar. I don’t know, keeping two wordpress installations actually sounded pretty nice to me, since it meant I didn’t have to try to write custom excludes for categories all over the place. Excludes that most likely involve mucking around in the wordpress theme php. Logging into my blog to update my blog, and my website to update my website seemed much more headache-free in the long run if I can get it set up correctly just once.
Sorry – I was away!
Alright, so one of my “static” pages, actually points to a category so I can dynamically add extra posts to that static page as needed and have them formatted nicely for me.
This is really unnecessary. You can simply create a category (say “blog”) that will hold all of your blog posts. Then create categories for your blog posts as children of “blog”. You can style “blog” however you like. There’s no need to use a query to pull in your posts – the method ias already set up for you quite simply, and using the method you have now can lead to troubleshooting issues (a big one I can think of is the issue with pagination – which gets munged when you use query_posts(); You can fix it, but if you just set it up as a category to being with, you don’t have to repair what doesn’t need fixin’ in the first place.)
How would I exclude this category from the blog nav-bar, while keeping all the blog-related categories?
Just don’t include it. Conditionals will allow you to display things based on what section of the site you’re on. And when WP 3.0 comes out (it’s in Beta testing right now, so this’ll happen probably by July or thereabouts) it’s made even easier to create your navigational systems.
I have a feeling you’re going to mention some way to exclude pages and categories from the navbar.
Yes, it’s called a conditional. You write 2 different navigational bars in your header or sidebar, which *include* (not exclude – exclude means every time you add something, you have to edit the theme to keep it from showing up) and based on the conditional, it’ll show or hide what you want. Takes literally five seconds (okay, it’ll take as long as it does to type it – so if you’re not a fast typist, it’ll take a little longer.)
since it meant I didn’t have to try to write custom excludes for categories all over the place. Excludes that most likely involve mucking around in the wordpress theme php. Logging into my blog to update my blog, and my website to update my website seemed much more headache-free in the long run if I can get it set up correctly just once.
But setting up two separate installations to accomplish something WP already does by default in a single installation is what will give you the headaches. The method I’m referring to up there is the fastest, easiest and most maintenance-free method.
Now, if you still want to set up 2 different installations, and try to use a single theme to make everything look the same, feel free. But you’re asking for the headaches you’re trying to avoid – and I doubt you’ll receive much help on it, since WP already does what you want by default. I don’t think anyone will bother to try it because what you’re asking to do is basically make twice as much work for yourself unnecessarily. I suppose it’s *possible* to pull off, but the real end question is “why?”
As the saying goes, if it ain’t broke, don’t fix it. If you want to customize your site, you *will* have to mess with the theme files – there’s simply no way around that no matter what you do. but the method I’m describing will get you going in minutes. What you’re trying to do will take days, and then you’ll be troubleshooting bugs all over the place for months and end up with a “WordPress sucks” attitude – which isn’t fair if you’re not using it correctly 😉
Thanks for writing such a long reply. I’ve given it a good long try and after thinking it over a bit I’m still not entirely sure you understand what I’m trying to do though. I want a blog on a single page of my wordpress website. I want to be able to have blog posts and pages on other parts of the website completely separate from the blog page. The website page is not going to have any blog navigation, the fact that I’m using pages, posts and categories to display the information on these parts of the website should be transparent to the user. Only the blog part should actually look like a blog.
Using the method of installing two wordpresses, if someone would help give me a clue, I could theoretically accomplish this. Since the only place the two wordpresses need to interact is at the header, where the navigation and a rotating tagline is displayed.
The reason I like this approach is that. 1. After the initial install there is virtually no maintenance. I can update the same theme on both blogs, and keep a minimum of plugins on the blog wordpress install (probably just email obfuscation). I can update my website area from my website wordpress, and my blog from my blog wordpress.
Using the method you suggested of only including a parent category is much easier for me to accomplish on my own, but has several more annoying drawbacks. 1. Including or excluding, no matter which method I use, it is still adding code to my theme that is hardcoded to my “blog” category. I have to update every single page in the theme to accomplish this. And should the design at any point change, I will have to change that hardcode. 2. It requires the small maintenance of making sure every blog post is in a category parented under the “blog.” Uncategorized blog posts will mysteriously disappear from my website. 3. I’m not sure why you mentioned having a pagination problem with including an entirely separate page, it seems that the bigger pagination problem is with including only the children of a parent category. next_posts_link and previous_posts_link weren’t built to search categories. wp_list_categories has a nice child_of parameter, but nothing else does. I’m going to have to research how to write a custom loop for everything that doesn’t.
So far, I’ve written custom conditional and loop statements for the archives and index, sidebar, and for recent posts to only include categories that are parented under the “blog” category, while not displaying “blog” itself anywhere. All that code seems like overkill if the right combination of php includes could combine two blogs into a blog within a blog. And yes, I’ve looked at that plugin blog-in-blog, and it doesn’t do what I want (it doesn’t work with a sidebar navigation).
If anyone could point me to a way to do what I originally asked, or perhaps a tutorial on the “parent category” approach, I would greatly appreciate it. Personally, I think this parent category approach seems more against the way wordpress is supposed to function than simply including one wordpress within another. But that’s just with the little I’ve found while customizing my theme and trying to place a blog in my website.
I want to be able to have blog posts and pages on other parts of the website completely separate from the blog page. The website page is not going to have any blog navigation, the fact that I’m using pages, posts and categories to display the information on these parts of the website should be transparent to the user. Only the blog part should actually look like a blog.
Yep, I understand this completely. This is totally doable with a single installation, and you can manage the single theme from the one installation.
1. Including or excluding, no matter which method I use, it is still adding code to my theme that is hardcoded to my “blog” category. I have to update every single page in the theme to accomplish this. And should the design at any point change, I will have to change that hardcode.
uhh… no. This is *completely* untrue. IF you choose to hardcode, then again, you’re making things more difficult for yourself, and what you’re saying might be true. but you don’t need to do that.
2. It requires the small maintenance of making sure every blog post is in a category parented under the “blog.” Uncategorized blog posts will mysteriously disappear from my website.
Again, no. You can set a category for your blog posts, and make it the default in your “settings” area.
3. I’m not sure why you mentioned having a pagination problem with including an entirely separate page,
Because when you create a static Page, and create theme ile to call in a category of posts to that page, you *will* have pagination issues (i.e. if your blog is set to show the most recent 10 posts, it’ll paginate when it hits post “11”. If you use a query – which you will within the page.php template to call in your posts – you have to use a special query so this pagination will not break. So if you’re keeping your blog and your site “separate”, then you might as well just use the category and forget about it – just link to the category rather than the page.
next_posts_link and previous_posts_link weren’t built to search categories.
Agian, you’re wrong. You can even remain in the same category if you so desire, so you can paginate through a single category – there’s a setting for that.
Good luck with your project.
I may have a means to resurrect this discussion and kill two birds with one stone. While I agree that the nature in which this topic was broached could easily be executed using one single installation, and one theme, I have a scenario in which the need to merge two theme header.php files “makes sense”.
I have a 6 site multisite installation, in which each department has a site which is in turn connected to social media, etc which is directed to that business segment’s specific audience. While I am currently the only one building / working with the site, I needed to make it flexible enough that non-technical users in each department are able to manage quite a bit of the content, display, and configuration of their department’s section of the site. To accomplish this, I used the Arras Theme (arrastheme.com). There’s more logic to these decisions, which I can explain if needed.
Moving on, one of the 6 sites is an online store. In order to accommodate future management of the online store by non-technical users, I am using WP e-Commerce and the Storefront Designer theme from StorefrontThemes.com.
That all said, the Storefront Designer theme has a single menu location, while Arras has two. There are some subtle differences in the rest of the header as well, but consistency in the navigation is the primary concern. Since the other 5 sections of the site all use the Arras theme, this is simple throughout, until I reach the store. The ideal resolution is to pull the header from Arras and use it to replace the header in Storefront Designer.
But I don’t know how to resolve the calling of arras functions in the header when the Arras theme is not the active theme.
Hopefully this example of such a need makes sense to you, and perhaps we can all collaborate to find an answer we can all benefit from.
Any insights greatly appreciated.
- The topic ‘Integrating Two WordPresses’ is closed to new replies.