WordPress.org

Ready to get started?Download WordPress

Forums

need help with wordpress add_action init to recognise is_single (2 posts)

  1. softplaza
    Member
    Posted 3 years ago #

    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

  2. saintist
    Member
    Posted 3 years ago #

    usage

    add_action('wp_head', 'my_function_init');

    or

    add_action('wp_footer', 'my_function_init');

Topic Closed

This topic has been closed to new replies.

About this Topic