• softplaza

    (@softplaza)


    I have,

    function my_function_init(){
        global $post;
        if(is_single()) {
            echo $post->ID;
        }
    }
    add_action('init', 'my_function_init');

    this doesn’t work for me, it doesn’t recognize if its a post even if its a post (is_single() = checks if its a post), i have this in the plugin i am writing for wordpress, please help

Viewing 1 replies (of 1 total)
  • saintist

    (@saintist)

    usage

    add_action('wp_head', 'my_function_init');

    or

    add_action('wp_footer', 'my_function_init');

Viewing 1 replies (of 1 total)
  • The topic ‘need help with wordpress add_action init to recognise is_single’ is closed to new replies.