• Hi! I’m modifying some code and am wondering if I’m doing something wrong. Instead of having it use the date (in Y-m-d format), I want it to use the post ID. The code’s purpose is basically defining a header image dynamically, based on the post ID. It worked with the date code, but doesn’t work with the post_ID code.

    Here’s the original code:
    <?php the_time('Y-m-d') ?>

    And here’s my modification:
    <?php the_ID(); ?>

    So the final code for the entire section would be:

    <div id="comic">
    <?php
    error_reporting(0);
    $gposts = get_posts('numberposts=1');
    foreach ($posts as $post) :
    ?>
    
    <?php echo '<img src="http://collegeandbeyond.org/headers/' ?>
    <?php the_ID(); ?><?php echo '.jpg" alt="Comic" />' ?>
    
    <?php
    endforeach;
    ?>
    </div>

    Any ideas?

    Thanks for the help!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Defining post ID via post_ID code?’ is closed to new replies.