This one is pretty weird.
This code:
$post->ID Displays right ID every time excepting the blog page (the page set as blog on /wp-admin/options-reading.php).
On that page $post->ID returns the ID of first blog post for given page.
Now, the tricky part, I've tried to remove all the loops from all my pages, totally erased loop.php file, disabled all the widgets that might have been affecting $post and it still returns the wrong ID.
Any hints?
My index.php is pretty standard:
<?php get_header();?> <?php get_template_part( 'loop', 'index' ); ?> <?php get_footer(); ?> And the loop.php is:
<?php while ( have_posts() ) : the_post(); ?> contents <?php endwhile; ?> Maybe the problem is I'm trying to get the ID in header.php?
And yes, wp_reset_postdata() doesn't seem to help as well :/
get_option('page_for_posts');.