I am trying to code a new wordpress theme from scratch and I am having problem as a ID for each post is not showing up as it supposed to do. This is the code I am using <div id="container"> <?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?> <div class="post"> <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <div class="entry"> <?php the_content(); ?> <p class="postmetadata"> <?php _e('Filed under:'); ?> <?php the_category(', ') ?> <?php _e('by'); ?> <?php the_author(); ?><br /> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?> <?php edit_post_link('Edit', ' | ', ''); ?> </p> </div> </div> <?php endwhile; ?> <?php else : ?> <div class="post" id="post-<?php the_ID(); ?>"> <h2><?php _e('Not Found'); ?></h2> </div> <?php endif; ?> Code (markup): Below is the source for my page
do yo mean this section ? <div class="post" id="post-<?php the_ID(); ?>"> <?php if(have_posts()) : ?> .... <?php else : ?> <div class="post" id="post-<?php the_ID(); ?>"> <h2><?php _e('Not Found'); ?></h2> </div> <?php endif; ?> PHP: that is the bit where you have no post, so you have no ID