Title: Posts Page ID
Last modified: August 21, 2016

---

# Posts Page ID

 *  [chrispink](https://wordpress.org/support/users/chrispink/)
 * (@chrispink)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/posts-page-id/)
 * I need to get the ID of the Posts Page as set in Settings->Reading.
 * the $post variable seems to only return information about the posts contained
   within the page how do I get the ID of the page itself?
 * I’m using the featured image in a banner (outside the loop) so I need the ID 
   to reference the thumbnail.

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

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/posts-page-id/#post-4179828)
 * Which template file are you working on?
 *  Thread Starter [chrispink](https://wordpress.org/support/users/chrispink/)
 * (@chrispink)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/posts-page-id/#post-4179887)
 * I’m making a child theme based on 2013. The template is the default template (
   unaltered) but I’ve replaced the custom header function with a banner based on
   the featured image – this code is within header.php
 * Which works on all single pages but not on the posts page. I haven’t made category
   pages yet but I’m guessing I may have the same problem
 * When I echo $post->ID I get the ID of the first post listed rather than the page
   itself.
 * Im using this;
    `$thumbnail_url = wp_get_attachment_image_src( get_post_thumbnail_id(
   $post->ID), 'full'); // set up for banner picture`
 * to retrieve the featured image URL.
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/posts-page-id/#post-4179910)
 * Which template **file** are you working on?
 *  Thread Starter [chrispink](https://wordpress.org/support/users/chrispink/)
 * (@chrispink)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/posts-page-id/#post-4179947)
 * Index.php
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/posts-page-id/#post-4179958)
 * the ‘posts page’ when set under _**dashboard – settings – reading **_has this
   ID:
 * `get_option('page_for_posts')`
 * try something like:
 *     ```
       if( is_home() && get_option('page_for_posts') ) { $page_id = get_option('page_for_posts');
       } elseif( is_page() ) { $page_id = $post->ID; }
       ```
   
 * (untested; details might need to be adapted to your existing code)
 *  [Scriptrunner (Doug Sparling)](https://wordpress.org/support/users/scriptrunner/)
 * (@scriptrunner)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/posts-page-id/#post-4179963)
 * To find the page that contains the posts (the listing of posts), you use:
 * `get_option('page_for_posts')`
 * as alchymyth said.
 *     ```
       $posts_page_id = get_option( 'page_for_posts' );
       echo "posts page id: " . $posts_page_id;
       ```
   
 * The caveat is that this value will only be set if you assign a static page for
   your front page and assign another page for your posts page (via Settings->Reading).
   When you run WordPress where the front page displays your blogs posts, that’s
   a special case and there is no “posts page” id. (actually, I think it comes back
   as 0).

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

The topic ‘Posts Page ID’ is closed to new replies.

## Tags

 * [$post->id](https://wordpress.org/support/topic-tag/post-id/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 6 replies
 * 4 participants
 * Last reply from: [Scriptrunner (Doug Sparling)](https://wordpress.org/support/users/scriptrunner/)
 * Last activity: [12 years, 11 months ago](https://wordpress.org/support/topic/posts-page-id/#post-4179963)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
