DexterR Posted September 18, 2009 Share Posted September 18, 2009 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! Quote Link to comment https://forums.phpfreaks.com/topic/174739-how-to-use-methods-from-the-same-2-included-files/ Share on other sites More sharing options...
KevinM1 Posted September 18, 2009 Share Posted September 18, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/174739-how-to-use-methods-from-the-same-2-included-files/#findComment-920880 Share on other sites More sharing options...
DexterR Posted September 18, 2009 Author Share Posted September 18, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/174739-how-to-use-methods-from-the-same-2-included-files/#findComment-920912 Share on other sites More sharing options...
mikesta707 Posted September 18, 2009 Share Posted September 18, 2009 yeah since you are trying to basically include the same class twice, 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 Link to comment https://forums.phpfreaks.com/topic/174739-how-to-use-methods-from-the-same-2-included-files/#findComment-920919 Share on other sites More sharing options...
KevinM1 Posted September 18, 2009 Share Posted September 18, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/174739-how-to-use-methods-from-the-same-2-included-files/#findComment-920921 Share on other sites More sharing options...
mikesta707 Posted September 18, 2009 Share Posted September 18, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/174739-how-to-use-methods-from-the-same-2-included-files/#findComment-920929 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.