Jump to content

Recommended Posts

I have two separate wordpress blogs and i'd like to display recent posts on one of them, from the other blog. So I need to use the same method, except from the other wordpress blog which connects to it's other database. My best stab at this was doing:

$secondaryBlog = include ("2ndBlog/wp-config.php");
$secondaryBlog->get_recent_posts();

 

But I get the error that $secondaryBlog is not an object. Is there some way to do this?

Thanks for any help!

Include isn't an assignable function.  That is, you can try to stuff the contents retrieved from it in a variable.  Instead, include and its related functions (include_once, require, and require_once) simply dump all of the included file's contents into the script at that point.

Include isn't an assignable function.  That is, you can try to stuff the contents retrieved from it in a variable.  Instead, include and its related functions (include_once, require, and require_once) simply dump all of the included file's contents into the script at that point.

Hrmm, is there a way I can accomplish what i'm looking to do?

Include isn't an assignable function.  That is, you can try to stuff the contents retrieved from it in a variable.  Instead, include and its related functions (include_once, require, and require_once) simply dump all of the included file's contents into the script at that point.

Hrmm, is there a way I can accomplish what i'm looking to do?

 

I've never played with Wordpress, but I'm sure there is.  You'd just need to connect to the other db, pull the correct results, and post them.  I can't tell you how to do that without seeing how Wordpress does it.

 

yeah since you are trying to basically include the same class twice' date=' IDK if there is a way to do this. perhaps if you rename the class from the wp-config file of the second blog, you could do it[/quote']

 

A better first step would be to see if the class can be instantiated multiple times, or can hold more than one database connection.  I wouldn't rename a class unless the Wordpress API forces it.

truth, I was thinking about that, but I wasn't sure if the database connection info was constant, or if you could modify it. I think its constant though, because when you set up wordpress I believe you it automatically creates its tables and what not. However, I could be making that up. more info is needed

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.