WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

It is possible that I'm doing something wrong. Currently I'm using index.php as the main blog page. I have a page setup for the Blog and set it up in my Settings. When I try to get the Blog Page ID though it always shows the first posts ID instead. I'm not running any additional queries anywhere besides the normal Loop.

Why is my code showing the Post ID versus the Page ID?

Index.php Code:

<?php get_header(); ?>

<?php get_sidebar(); ?>

    echo $post->ID;  // First Post ID
    echo get_queried_object_id(); // First Post ID

<div id="content" class="blog">
<?php if(have_posts()) : ?>
                <?php while(have_posts()) : the_post(); ?>
                    <div <?php post_class('blog-entry') ?> id="post-<?php the_ID(); ?>">
                            <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
                                <?php the_title(); ?>
                            by Company <?php the_time('F jS, Y') ?> / 
                            <a href="<?php the_permalink(); ?>/#comments">Share Comment</a>

                        <div class="entry">
                            <?php the_excerpt(); ?>

                        <p class="postmetadata">
                            <span style="text-align: left; float: left;">
                                <a href="<?php the_permalink(); ?>" title="Read More">Continue Reading &raquo;</a>
                        <div class="clear"></div>
                <?php endwhile; ?>
                <div id="blogNav">
                    <span class="prev"><?php previous_posts_link('&laquo; Previous Page'); ?></span>
                    <span class="next"><?php next_posts_link('Next Page &raquo;'); ?></span>
            <?php endif; ?>
<?php get_footer(); ?>
share|improve this question
We would have to see your code to tell you anything about it. – Charles Clarkson Aug 30 '13 at 17:06
Updated my question, it's all pretty standard though. – Howdy_McGee Aug 30 '13 at 17:18
up vote 1 down vote accepted

the 'posts page' ID when using a static front page and a different posts page is:

get_option( 'page_for_posts' )

in some context:

if( is_home() && get_option( 'page_for_posts' ) ) { 
  $page_ID = get_option( 'page_for_posts' ); 
share|improve this answer
Cool, good to know. I jtus find it strange it doesn't use the page ID. – Howdy_McGee Aug 30 '13 at 19:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.