WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Different post structure for post in different category (3 posts)

  1. Terry
    Member
    Posted 5 years ago #

    I've tried searching through the codex but I couldn't find a way to do this: I categorize posts in a certain category such that I will include an excerpt due to their length, however, I would like to display them alongside with other full-length posts (in other categories) on the main page, in the loop.

    In other words: Is there anyway to exclude the posts from the category, insert the_excerpt and display them posts alongside with other posts in the loop?

    How is that achievable? Thanks!

  2. renato_s
    Member
    Posted 5 years ago #

    Not sure if I understood what you want. You want to display posts from a certain category with the excerpt in the home, alongside with full content posts from the other categories, is that correct?

    If it is, then put this in your Loop, replacing the "the_content()" tag:

    <?php if (in_category('3')) the_excerpt(); else the_content(); ?>

    Replace 3 by the ID of the category you want to show the excerpts.

  3. Terry
    Member
    Posted 5 years ago #

    Wow, thank you so much! It worked like a charm... I never knew you can use conditional comments in the loop as well. Thanks again!

Topic Closed

This topic has been closed to new replies.

About this Topic