WordPress.org

Ready to get started?Download WordPress

Forums

Finding out the category (5 posts)

  1. goldfish654
    Member
    Posted 9 years ago #

    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?

  2. Beel
    Member
    Posted 9 years ago #

  3. goldfish654
    Member
    Posted 9 years ago #

    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.

  4. Beel
    Member
    Posted 9 years ago #

    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.

  5. goldfish654
    Member
    Posted 9 years ago #

    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).

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.