Decaflon

Welcome to Decaflon! Where the geeks hang out: Signup or Login Here
Decaflon is proudly hosted by (mt) Media Temple.  We recommend them for your web hosting needs.
Clips: Popular Clips Upcoming Clips Notes: All Notes

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!

Would this work?

username Zoom

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.

You could do this, too:

save this in a file called feedinc.php on the site that you want to include:

<?php
require_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.

Should I use /mnt/Target01/328146/ like you included?

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... ;)

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..!

after some digging, I think its the number after Target01 that is unique to you.. now I need to figure mine out!

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?

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.

Jackosh, let me ask my mom if she remembers what she did. I'll be back...

thank her for me :) I appreciate you going out of your way for me!

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...

I'm using 2.2

Hmm, that may be what the issue is, but I'll ask her anyway, because she still might know how to help. Later...

Okay, how about this in the feedinc.php file:

<?php
require('./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...

trying it now, thanks!

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!

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.

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!

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..

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?

How about some more info about what you're trying to do?

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!

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!

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?

@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.

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

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...

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..

Please Login To Leave A Comment

Decaflon Sponsors Get in touch if you want in.

Hot Notes (View all »)

 

Decaflon is part of the Chawlk Network of sites.

9 Great Places To Visit, Hang Out, & Meet New People

What's new and interesting at other Chawlk Network sites: