Jump to content

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!

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.