0

hi i used wp_head a couple of times.I echoed some values it works like below

function test()
{
echo "hello am visible";
}
add_action('wp_head','test');

but if i store a php code in db and retrieve it to a variable and echoed it is not working, here is the sample

<?php echo "i will go to db and come again"; ?>

i stored the above value in LONGTEXT format in db as trial then i selected the table and assigned it to a variable like below

$output = $result->trial;

Here come the problem part

function test()
    {
    //after retrieve 
    echo $output;
    }
add_action('wp_head','test');

this way it is not working.i can't able to see i will go to db and come again. What is the problem? Thanks

10
  • What do you see instead?
    – shea
    Sep 3, 2013 at 10:40
  • same <?php echo "i will go to db and come again"; ?> if i show it in div.but if i don't show it in div i can't able to see it.
    – sun
    Sep 3, 2013 at 10:50
  • Anything in wp_head won't be visible in the browser. You need to view the page source (Ctrl/Cmd+U)
    – shea
    Sep 3, 2013 at 10:53
  • i'm getting the same <?php echo "i will go to db and come again"; ?> code not the interpreted source
    – sun
    Sep 3, 2013 at 10:56
  • Oh, I see. You want to execute the PHP code. You'll need to use the eval() function. Though you really shouldn't be doing this…
    – shea
    Sep 3, 2013 at 11:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.