• Resolved Lou Sparx

    (@roulettered)


    Hi guys,

    I’m trying to move some PHP code from my Functions.php to my Header.php.

    function hello() {
    global $post;
    if (!is_single()) {
        return;
    }
    
    //print_r($post);
    $pony = strip_tags($post->post_content);
    $pony = str_replace(array('"',"'", "\n", "\r", "\t"), ''', $pony);
    
    echo "$pony";
    }
    
    add_action('wp_head', 'hello');

    I’ve tried:

    <?PHP {
    global $post;
    if (!is_single()) {
        return;
    }
    
    //print_r($post);
    $pony = strip_tags($post->post_content);
    $pony = str_replace(array('"',"'", "\n", "\r", "\t"), ''', $pony);
    
    echo "$pony";
    }
    
    ;?>

    etc.. But this doesn’t work.

    Any help would be much appreciated.

    Thanks,
    Lou

Viewing 16 replies (of 16 total)
Viewing 16 replies (of 16 total)

The topic ‘Moving Function to Header..’ is closed to new replies.