• Resolved jammylammy

    (@jammylammy)


    Hi all,

    I have two categories on my site: ‘links’ and ‘miscellaneous’. ‘Links’ are quick, del.icio.us style snippets that I want to be quick and easy to view. Everything else (long ramblings, jokes etc. etc.) will go under the ‘misc’ category.

    What I need to do on my homepage is setup something like (and please excuse the formatting of this!):


    if (category==links)
    then
    only display the_content()
    else
    display the_title(), the_content() and the_date()

    for each posting. Does anyone have any ideas on the best way I can achieve this? I’ve had a go at seperating out the categories, but it displays ALL the links at the top and then all the other content. I want both categories to be displayed chronologically, so that links become interspersed with main content depending on their authored-on date.

    Any help greatly appreciated. Many thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Oops.

    if (in_category(XXX))
    {
    ?>
    <p><?php the_content ?></p>
    <?php
    }
    else
    {
    ?>
    <h2><a class="morelink" href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    <p class="date"><?php the_date() ?></p>
    <p><?php the_content ?></p>
    <?php
    }
    ?>

    Something like that should work. XXX should be replaced with the category ID number for your “links” category.

    Thread Starter jammylammy

    (@jammylammy)

    Brilliant! Thanks very much for that. The actual code that I got down to was:


    <?php
    if (in_category(1)) //cat1 = most normal posts
    { ?>
    <div id="postHolder">
    <h2><?php the_title()?></h2>
    <h3><?php the_date()?></h3>
    <?php the_content();?>
    </div>
    <?php } else { ?>
    <div id="linkHolder">
    <?php the_content();?>
    </div>
    <?php
    }
    ?>

    Once again, many thanks tsguitar.

    Cool. Can you mark this “Resolved”?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Customise display of posts depending on category’ is closed to new replies.