Calling wordpress from within a function
-
Hello,
I am trying to embed a blog into an existing webpage. I tried this in the following way:
The existing webpage is implemented using Smarty, a template engine. Since I am trying to give template authors the possibility to embed a blog into whatever template they choose, the only way is to register a function to Smarty, which is then made accessible to the template.
The bottom line is: A function needs to be passed to Smarty that returns the complete blog.
However, doing something like this:———-
define(‘WP_USE_THEMES’, true);function show_blog() {
require(‘wordpress/wp-blog-header.php’);
}$s = &new Smarty();
$s->register_function(“blog”, “show_blog”);
———-produces the following error message:
—————–
Fatal error: Call to a member function on a non-object in /home/www/wordpress/wp-includes/functions.php
—————–When calling require() in global scope it works, but this will obviously not integrate with the template engine. Is there an easy way to achive something similar?
(note for the Smarty-experienced folks:
“{php}require(‘wordpress/wp-blog-header.php’);{/php}”
produces the same problem; the snipped is called from within a function)Thanks,
-Samuel
- The topic ‘Calling wordpress from within a function’ is closed to new replies.