How to run php code in smarty template file?

I want to load wordpress in a smarty template. I used the code below to load wordpress in a php file and it worked. But it is not working a smarty template.

In php file:

Read More
<?php
include $_SERVER['DOCUMENT_ROOT'].'/wordpress/wp-load.php';
get_header();
?>

In smarty template file:

{php}
include $_SERVER['DOCUMENT_ROOT'].'/wordpress/wp-load.php';
get_header();
{/php}

Related posts

Leave a Reply

2 comments

  1. Are you using Smarty3? Have a look here.

    {php} tag is deprecated, and from version 3.1 it’s only available using SmartyBC class instead of Smarty class. They are just the same, but if you instance a new SmartyBC() object you will have a backward-compatible Smarty object supporting {php} tags.

  2. <?php
                 if( isset($_SESSION['ERRMSG_ARR']) && is_array($_SESSION['ERRMSG_ARR']) && count($_SESSION['ERRMSG_ARR']) >0 ) 
                 {
                    echo '<ul class="err">';
                    foreach($_SESSION['ERRMSG_ARR'] as $msg) 
                    {
                        echo '<li>',$msg,'</li>'; 
                        }
                    echo '</ul>';
                    unset($_SESSION['ERRMSG_ARR']);
                    }
                ?>