Support » Fixing WordPress » Different post structure for post in different category

  • Resolved Terry

    (@wherewillyoube)


    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!

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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.

    Terry

    (@wherewillyoube)

    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!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Different post structure for post in different category’ is closed to new replies.