Title: Getting a post from its permalink?
Last modified: August 31, 2016

---

# Getting a post from its permalink?

 *  Resolved [joyner.cn](https://wordpress.org/support/users/joynercn/)
 * (@joynercn)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/getting-a-post-from-its-permalink/)
 * If I have the string ‘bob’, how do I get the title of the post with the permalink
   mysite.com/bob?
 * Right now I’m trying:
 *     ```
       $value = 'bob';
       $thispost = get_post($value);
       echo '<li>' . $thispost->post_title . '</li>';
       ```
   
 * However, that isn’t returning anything. Needless to say, $value is coming from
   somewhere else, but when I print $value directly, it’s the right text — so it’s
   the last step I’m unsure about.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/getting-a-post-from-its-permalink/#post-7286416)
 * `get_post()` is mainly used to get the post object when we already know the post
   ID. It does not work with titles or slugs. The most flexible way to get a particular
   post is `get_posts()`, even though it is intended for getting multiple posts,
   it can get a single post just as well. Just remember that it returns an array
   of posts, even if there is only one post in the array.
 *     ```
       $value = 'bob';
       $thispost = get_posts("name=$value");
       echo '<li>' . $thispost[0]->post_title . '</li>';
       ```
   
 *  Thread Starter [joyner.cn](https://wordpress.org/support/users/joynercn/)
 * (@joynercn)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/getting-a-post-from-its-permalink/#post-7286434)
 * That did it, thank you so much!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Getting a post from its permalink?’ is closed to new replies.

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 2 replies
 * 2 participants
 * Last reply from: [joyner.cn](https://wordpress.org/support/users/joynercn/)
 * Last activity: [10 years, 1 month ago](https://wordpress.org/support/topic/getting-a-post-from-its-permalink/#post-7286434)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
