Title: Getting a specific post with WordPress &#8211; Finding a good practice
Last modified: August 12, 2017

---

# Getting a specific post with WordPress – Finding a good practice

 *  [benherzliya](https://wordpress.org/support/users/benherzliya/)
 * (@benherzliya)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/getting-a-specific-post-with-wordpress-problem-with-post/)
 * I have a custom post type, called Models. I’m trying to retrive a specific post/
   model (‘model-a’).
 * What would be a best practice for achieving this?
 * I read this can be done with get_page_by_title function. However I tried this
   code:
    `print_r(get_page_by_title('model-a', OBJECT, 'model'));` and this code:
 *     ```
       $page = get_page_by_title('model-a', OBJECT, 'model')
       print_r($page)
       ```
   
 * and it printed nothing to my screen.
    Print_r should print “Prints human-readable
   information about a variable” so I understand there is some problem with my get_page_by_id.
 * Any suggestions?
    -  This topic was modified 8 years, 9 months ago by [benherzliya](https://wordpress.org/support/users/benherzliya/).
      Reason: style
    -  This topic was modified 8 years, 9 months ago by [benherzliya](https://wordpress.org/support/users/benherzliya/).

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

 *  [Jacob Peattie](https://wordpress.org/support/users/jakept/)
 * (@jakept)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/getting-a-specific-post-with-wordpress-problem-with-post/#post-9404057)
 * What’s the context here? What are you retrieving it for and what will you be 
   doing with it?
 * With your specific code the problem appears to be that you are using the model
   _slug_, rather than the title. Try:
 *     ```
       get_page_by_path('model-a', OBJECT, 'model')
       ```
   
    -  This reply was modified 8 years, 9 months ago by [Jacob Peattie](https://wordpress.org/support/users/jakept/).
 *  [chrispink](https://wordpress.org/support/users/chrispink/)
 * (@chrispink)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/getting-a-specific-post-with-wordpress-problem-with-post/#post-9404302)
 * Use get_post() using the post ID for ‘model-a’
 * $post_7 = get_post( 7 );
    $title = $post_7->post_title;
 * print_r is for arrays, what you are dealing with is an object you need var_dump
 * var_dump($post_7);
 * [https://developer.wordpress.org/reference/functions/get_post/](https://developer.wordpress.org/reference/functions/get_post/)

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

The topic ‘Getting a specific post with WordPress – Finding a good practice’ is 
closed to new replies.

## Tags

 * [functions](https://wordpress.org/support/topic-tag/functions/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 2 replies
 * 3 participants
 * Last reply from: [chrispink](https://wordpress.org/support/users/chrispink/)
 * Last activity: [8 years, 9 months ago](https://wordpress.org/support/topic/getting-a-specific-post-with-wordpress-problem-with-post/#post-9404302)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
