kt83 Posted July 28, 2009 Share Posted July 28, 2009 Hi All, I'm trying to display the results of a WP plugin on a page that isn't wordpress driven. I was told that these two lines of codes should do the trick: <?php require_once("/home/useracct/public_html/wordpress/wp-config.php"); ?> <?php echo recent_posts(); ?> On my site, I use .tpl (template) files and .php files to push the templates. I've already created the space where I want the results to appear on the user side but I don't know how to implement it. So where would I include these two lines of PHP codes? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/167874-using-wp-plugin-outside-of-wordpress/ Share on other sites More sharing options...
ldougherty Posted July 28, 2009 Share Posted July 28, 2009 This thread should be helpful. http://wpengineer.com/embed-wordpress-functions-outside-wordpress/ You should place the require in the core PHP file. Quote Link to comment https://forums.phpfreaks.com/topic/167874-using-wp-plugin-outside-of-wordpress/#findComment-885419 Share on other sites More sharing options...
kt83 Posted July 29, 2009 Author Share Posted July 29, 2009 Hi Larry, Thanks for the tip. I've looked at that article before but it's not quite what i'm looking for. This is how my site works: I have a home.php file which has the following codes: <?php /* Check Structure Availability */ if (!defined("CORE_STRAP")) die("Out of structure call"); $tpl = new template; $tpl -> Load("home"); $tpl-> CleanZones(); $tpl -> Flush(); ?> Then I have a home.tpl file which has the html for the content. Let's say I want to place the output of the plugin in the middle of my content area, how would I do that? thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/167874-using-wp-plugin-outside-of-wordpress/#findComment-885536 Share on other sites More sharing options...
kt83 Posted July 31, 2009 Author Share Posted July 31, 2009 UPDATE: This is what my home.php file looks like: <?php $tpl = new template; $tpl -> Load("!theme/{$GLOBALS["THEME"]}/templates/home.tpl"); $tpl -> GetObjects(); require_once("home/www/sitename/blog/wp-config.php"); $recentPosts = recent_posts(); $recentComments = get_recent_comments(); $tpl -> AssignArray(array('recent.posts' => '$recentPosts')); $tpl -> AssignArray(array('recent.comments' => '$recentComments')) $tpl-> CleanZones(); $tpl -> Flush(); ?> And inside my home.tpl file, I have, in two different divs, {recent.posts} and {recent.comments} On the page, the recent_posts and recent_comments appear before all the content and in the div where I placed {recent.posts}, appears $recentPosts and {recent.comments} appears $recentComments. I tried it without the ' ' around $recentPosts and $recentComments, but nothing came out. Hope you can figure this out. Thanks for your help! Quote Link to comment https://forums.phpfreaks.com/topic/167874-using-wp-plugin-outside-of-wordpress/#findComment-887969 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.