WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Having code appear only on posts above a certain ID (3 posts)

  1. Bodhipaksa
    Member
    Posted 4 years ago #

    I've been manually putting an author bio and image at the foot of the content of all posts, but I'd like to automate this. I'll be putting something like this in my single.php:

    <div id="author-info">
        <div id="author-image">
        	<a href="<?php the_author_meta('user_url'); ?>"><?php echo get_avatar( get_the_author_meta('user_email'), '80', '' ); ?></a>
        </div>
        <div id="author-bio">
            <h4>Written by <?php the_author_link(); ?></h4>
            <p><?php the_author_meta('description'); ?></p>
        </div>
    </div>

    However I don't want this to appear on older posts, which already have the bio as part of the post content. Is there some kind of conditional statement I can wrap this in that will cause it to appear only on posts with IDs higher, than, say 7396 (the most recent post with the bio manually added).

    Thanks!

  2. MichaelH
    Member
    Posted 4 years ago #

    <?php
    if ($post->ID > 146) {
    echo 'this post had id greater than 146 '.$post->ID;
    }
    ?>
  3. Bodhipaksa
    Member
    Posted 4 years ago #

    Thank you so much! That was just what I needed.

Topic Closed

This topic has been closed to new replies.

About this Topic