WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Get Post Id (5 posts)

  1. Nasir Zia
    Member
    Posted 2 years ago #

    Hi,
    I know its too basic, but i am unable to sort this out..
    How can we get a current post id inside a plugin...

    Thanks,
    Nasir

  2. Tom
    Member
    Posted 2 years ago #

    This should help:

    function yourpluginname_get_post_id()
    	{
    		global $wp_query;
    		$post = $wp_query->post; //get post content
    		$id = $post->ID; //get post id
    
    		//do things with the post id
    
    	}
  3. Aaron
    Member
    Posted 2 years ago #

    *Edited post since answer is above.

  4. Nasir Zia
    Member
    Posted 2 years ago #

    Great!
    it worked.
    Thanks alot!

  5. Tom
    Member
    Posted 2 years ago #

    Glad it worked! Please mark your topic as "resolved".

Topic Closed

This topic has been closed to new replies.

About this Topic