Accessing a different WP install on my blog
Written By jackosh on Jun. 8, 2007.
28 Comments
Report Note
+ Clip This
I have something that I would really like to do, but I'm not too sure how possible it is.
I have a blog at one address. I would like to access a WP install at another blog address of mine, to display those posts using a *special wordpress loop. I have full access to the mySQL server of the other address.
Is this even possible? Any ideas of how I could do this?
Thanks!

dreamweaver
Written Jun. 8, 2007 / Report /
Would this work?
Oli
Written Jun. 8, 2007 / Report /
It seems silly to convert out to another format when you have the raw data just sitting there...
I think you'd have to hack it in pretty manually but I can't see why it couldn't be done.
dreamweaver
Written Jun. 8, 2007 / Report /
You could do this, too:
save this in a file called feedinc.php on the site that you want to include:
<?phprequire_once("/mnt/Target01/328146/www.yourdomain.com/web/content/your-blog-directory/wp-blog-header.php");
define('WP_USE_THEMES', false);
?>
<?php wp_get_archives('type=postbypost&limit=5'); ?>
then access it from the page you want it to show up like this:
<ul><?php include ("http://www.yourdomain.com/feedinc.php") ?></ul>I have no idea why this works, my mom made it up for me over a year ago, but I use it all the time. You can style it with CSS as well.
jackosh
Written Jun. 8, 2007 / Report /
Should I use
/mnt/Target01/328146/like you included?dreamweaver
Written Jun. 8, 2007 / Report /
Um, I'm not really sure, because I don't know why this works. There are no directories like that on my site, so I'm guessing it needs to be there just as is for whatever reason, but I don't know why. I've never been able to figure out why that works, but it does. Try it, the worst that can happen is it won't work for you, then I can stay up half the night testing it on my other sites to figure out why... ;)
jackosh
Written Jun. 8, 2007 / Report /
hmm I can't seem to get that to work- I think it has something to do with some of that code that is probably unique to the server you're on.. I'm trying to work with that general idea though..!
jackosh
Written Jun. 8, 2007 / Report /
after some digging, I think its the number after
Target01that is unique to you.. now I need to figure mine out!Devin
Written Jun. 8, 2007 / Report /
I believe the location should simply refer to your directory, jackosh. For example, on DreamHost my WordPress install is located at: /devinreams.com/public_html/wp-blog-header.php
Does that make sense?
jackosh
Written Jun. 8, 2007 / Report /
It would make a lot of sense, but I just can't seem to get it going!
Here is the code I'm playing with:
<?php
require_once("/mydomain.net/wordpress/wp-blog-header.php");
define('WP_USE_THEMES', false);
?>
<?php wp_get_archives('type=postbypost&limit=5'); ?>
highfivehero.net is just a domain of mine that I setup a dummy wp install to test this.. but still, no dice.
dreamweaver
Written Jun. 8, 2007 / Report /
Jackosh, let me ask my mom if she remembers what she did. I'll be back...
jackosh
Written Jun. 8, 2007 / Report /
thank her for me :) I appreciate you going out of your way for me!
dreamweaver
Written Jun. 8, 2007 / Report /
Oh, what version of WP are you running? That might have something to do with it, since I'm on 2.0.whatever, not 2.1.whatever or 2.2...
jackosh
Written Jun. 8, 2007 / Report /
I'm using 2.2
dreamweaver
Written Jun. 8, 2007 / Report /
Hmm, that may be what the issue is, but I'll ask her anyway, because she still might know how to help. Later...
dreamweaver
Written Jun. 8, 2007 / Report /
Okay, how about this in the feedinc.php file:
<?phprequire('./wordpress/wp-config.php');
define('WP_USE_THEMES', false);
?>
<?php wp_get_archives('type=postbypost&limit=5'); ?>
I found a support topic in the WP forum that uses that instead. This line also works for me on my site. Let me know if it works for you, Jackosh. Mom doesn't seem to be connected at the moment...
jackosh
Written Jun. 8, 2007 / Report /
trying it now, thanks!
jackosh
Written Jun. 8, 2007 / Report /
so that would work, the only problem is that the other install is on a completely different domain (same sql server/ftp though).. so I need it to point there!
dreamweaver
Written Jun. 8, 2007 / Report /
Okay, wait, I use this on Driven to Quilt, and the posts it pulls in are from DreamWeaver's Quilts. The feedinc.php file is on DreamWeaver's Quilts, and the line to include the feedinc.php file is on Driven to Quilt.
So, blog #1 is where you want the posts/titles to show up, and that's where you put
<ul><?php include ("http://www.yourdomain.com/feedinc.php") ?></ul>Blog #2 is where the posts came from, and that's where you put feedinc.php. I have it in the root of the site, not in the wordpress directory.
Once you get it to work, you can adjust the wp_get_archives function call to show the whole post, which I might be able to figure out how to do here in a bit.
jackosh
Written Jun. 8, 2007 / Report /
well I'm just about there- http://highfivehero.net/x-tumble.php works fine, but the include statement is not working.. I'm not giving up yet, though!
jackosh
Written Jun. 8, 2007 / Report /
OK it does work, BUT only when I take out
require('./wordpress/wp-config.php');and I assume its because it freaks out with two wp-config files loaded..dreamweaver
Written Jun. 8, 2007 / Report /
How about some more info about what you're trying to do? I have some thoughts, and a couple of other solutions.
If you want the entire post from blog#2 to show on blog#1, you can do that by programming an entire wp loop into the feedinc.php file. No matter whether you want to just have post titles or the entire post, the call to the feedinc.php file cannot be inside the existing wploop on blog#1. If it is inside the wp loop that's already there, you'll have problems with page navigation on for the posts on blog#1.
The links in the imported blog#2's posts will link to the other site, of course.
Other solutions: Check out magpie. Converts rss to html, then spits it out to be included wherever.
Mom said something about WPGet as well.
Thoughts?
jackosh
Written Jun. 8, 2007 / Report /
I run a blog (linked to from y my.9r page). I also want to run a tumblelog (at a separate address). While I will run the tumblelog at a separate address, I would also like to show the most recent posts at my main blog address on its own page (still linking back to the tumblelog).
I think I have it 90% done thanks to your help so far, I just need to figure out how to run the wordpress code from the tumblelog address without 'confusing' the wordpress code at the main blog address!
I'm not calling it from within a WP loop. magpie and wpget are not ideal for me, though I guess at some point I'll realize that beggar can't be choosers!
dreamweaver
Written Jun. 8, 2007 / Report /
Well, I was able to do some testing on my own two blogs earlier, and if you just dump the entire wordpress loop into the feedinc.php file, from
<?php if (have_posts()) : ?>to
<?php endif; ?>it works, and then you can customize it down so as not to include things you don't need/want to show up there, like the comments code, and navigation. It will show however many posts from blog#2 that you've set blog#2 to show in it's options panel. It worked for me on the two sites I linked to earlier, though I only had it up to test functionality.
Let us know when you get it working, and what you did!
JeffJ
Written Jun. 8, 2007 / Report /
Maybe I'm missing the point of what you're trying to do here, but couldn't you just use information from the feed of one blog to get those latest posts to display on the other? That would be similar to what 9rules does with grabbing the latest posts from its members' personal blogs.
It just sounds to me like you're using a slightly convoluted method that's using extra mysql queries that could be avoided. No?
jackosh
Written Jun. 8, 2007 / Report /
@dreamweaver:
I'm messing around now, I'll post back soon :)
@JeffJ:
I could do that, but it is not what I want to do.. feeds don't let you customize everything, as I would like to do.
jackosh
Written Jun. 8, 2007 / Report /
here are my warnings:
Warning: require(./wordpress/wp-config.php) [function.require]: failed to open stream: No such file or directory in /home/.server/username/mydomain.net/x-tumble.php on line 5
Fatal error: require() [function.require]: Failed opening required './wordpress/wp-config.php' (include_path='.:/usr/local/php5/lib/php') in /home/.server/username/mydomain.net/x-tumble.php on line 5
dreamweaver
Written Jun. 9, 2007 / Report /
Hey, sorry to be gone Jackosh. Bedtime in my part of the world. Did you get this going last night?
If not, send me a friend request, and we can do this by PM or email. I've tried this with the info you have and it works and I can see the "Hello, World" post, so I'm not sure why it doesn't for you. Let me know...
jackosh
Written Jun. 9, 2007 / Report /
just sent the friend request :)
I think it has to do with the fact that I'm on Dreamhost. My blog seems to be executing the code according to its own database, instead of the highfivehero database..