WordPress Get Post ID by various parameters

This tutorial helps you to find the POST ID by various ways of various need. During theme or plugin developments we may need to get the post id on demand by some specific parameter like ‘current post’, ‘current page’ etc.

So here i tried to sort out all of theme.

GET POST ID OF CURRENT PAGE/POST:

# This function works anywhere outside of loop.

# If you want get POST ID inside the loop you can use:

GET POST ID BY TITLE:

specially uses for getting page id.

GET POST ID OF FRONT PAGE (HOME PAGE):

 

GET POST ID OF POSTS PAGE (BLOG PAGE):

GET POST ID BY SLUG:

 

GET POST ID BY URL:

 

Hope this post helps you lot to find out basic ways to GET POST ID in various requirements. Still if you need any other wasy then feel free to drop a message. We will answer you shortly for your solution.

Thanks.

This post has already been read 7631 times!

Mehedi Hasan

Cool WordPress Developer having much agile experience to develop any kind of WordPress sites & plugins. Also good in troubleshooting, fixing & making any kind of tweaks for WP site.

More Posts

Mehedi Hasan

Cool WordPress Developer having much agile experience to develop any kind of WordPress sites & plugins. Also good in troubleshooting, fixing & making any kind of tweaks for WP site.

2 thoughts on “WordPress Get Post ID by various parameters

  • April 13, 2017 at 2:01 pm
    Permalink

    Hello,
    I want post id by url not by published url not by permalink.
    this function not working.

    please help..

    Reply
    • May 4, 2017 at 7:42 pm
      Permalink

      Hi gaurav kumar,
      not clear with your question. Give me an example please.
      Thanks.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *