WordPress.org

Support

Support » Themes and Templates » Finding out the category

Finding out the category

  • goldfish654

    @goldfish654

    On the front page, I want to show only the excerpts for the posts, except int the “personal” category. So far i have the following code :
    <?php
    if ($_GET['cat'] || $_GET['p']) { the_content(); } else {
    the_excerpt(); } ?>

    So that works out if its the front page fine. What I want to do is have it find out if the post its outputting is in Catid 1. How would I do that?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Take a look at Matt’s “asides”
    http://codex.wordpress.org/User:Matt/photomatt.net

    goldfish654

    @goldfish654

    Thanks!
    He says he uses a function in_category(), but it doesnt seem to work in my version (1.2) where could I get the code for this function from?
    <?php if (in_category(33) && !$single) { ?>
    If I had the function this would be just the ticket.

    You have it otherwise you would get a fatal error when calling it. There is more than just the function, you also have to add “stuff” 😉 Take a good look at the directions and search here as there is plenty on how to set it up.

    goldfish654

    @goldfish654

    I worked it out 🙂
    <?php
    if (!in_category(1) && !$single) {
    the_excerpt(); ?>
    " rel="bookmark" title="Permanent Link: <?php the_title(); ?>">Read More.... <?php
    } else {
    the_content();
    }
    ?>

    Theres the code I ended up with. Checks if its in category 1, and also whether its in a single page (so when they click Read More it shows the full text).

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Finding out the category’ is closed to new replies.