Forums

[resolved] Display the_content or the_excerpt dependent on $author_id (2 posts)

  1. Tony2Nice
    Member
    Posted 9 months ago #

    Basically what it says in the title.

    I'm trying to set up a conditional that says "if the author id is "1", display the_content, else display the_excerpt." Problem is, I'm not much with php syntax. I've got this so far:

    <div class="entry">
    <?php if ( $author_id == '1' ) { ?>
    <?php the_content(''); ?>
    <?php } else { ?>
    <?php the_excerpt('Continue reading &raquo;'); ?>
    <?php } ?>
    </div><!--/entry -->

    Thanks in advance for any help.

  2. Tony2Nice
    Member
    Posted 9 months ago #

    Ok, cool, I got it working by changing "$author_id" to "get_the_author_id()". Full code:

    <div class="entry">
    <?php if ( get_the_author_id() == '1' ) { ?>
    <?php the_content('Continue reading &raquo;'); ?>
    <?php } else { ?>
    <?php the_excerpt('Continue reading &raquo;'); ?>
    <?php } ?>
    </div><!--/entry -->

    Hope this is useful for someone else too.

Reply

You must log in to post.

About this Topic