johnnietheblack
johnnietheblack

Reputation: 13340

Wordpress loop inside of function = fatal error

I have my Wordpress blog on blog.mysite.com, and a totally different site (built in my framework) at www.mysite.com.

I know if the blog and another site are on the same server, and have correct permissions, I can use the following to "syndicate" my blogs to the non-blog site with:

define('WP_USE_THEMES', false);
require('/var/www/vhosts/mysite/subdomains/blog/httpdocs/wp-config.php');
query_posts('showposts=5');

...and then run a loop on the page.

The problem is that since my non-blog site is a framework, everything except for my front controller lives in a function - and this is creating the following error for me:

Fatal error: Call to undefined method stdClass::set_prefix()

(btw, I'm fairly certain the fact that this code is called within a function that is causing the error...when I put the code on the front controller (not in function), the error disappears)

I would REALLY like to have recent blog listings on my non-blog site to spruce it up. Any ideas on how to do this?

Upvotes: 0

Views: 451

Answers (1)

Atif
Atif

Reputation: 10880

Well I guess you forgot to write

global $wpdb

inside the function

Upvotes: 1

Related Questions