How to get a post id by using title in wordpress

How to get a post id by using title in wordpress

In this post we will show you how to get the Post ID by Title. If you have the title of a post or page and you want to get the post id then please use following code.

<?php

$title = “Hello world”;   // You can use your own title

$result = get_page_by_title($title, “OBJECT”, “post”);  // post type e.g. post, page, product etc

echo $result->ID; // this will be your required result / ID

?>

 

Please watch the video for better understanding.

Leave a Comment