Jump to content

using WP plugin OUTSIDE of wordpress.


kt83

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/167874-using-wp-plugin-outside-of-wordpress/
Share on other sites

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.

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!

Archived

This topic is now archived and is closed to further replies.

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