Support » Fixing WordPress » <?php if (is_category()) { ?> function?

  • I’m trying to display the 1st post in my archives and the rest as a list.
    I read a truncated post in here wich suggested installing a counter with code to count, and “if” post 1 then show the post. if post is not one, then display a list.
    A. this is way over my head.
    B. it’s not quite what i want to do. displaying as a “list” doubles the titles in the archives. what i’ve taken to doing is simply removing the call tag (no post, no title, no excerpt) and just left the permalink and the metadata below it. Makes the kind of list i want.
    So my question is:
    using this new tag:
    <?php if (is_category()) { ?>
    can i tell the archives.php that “if” this is a caegory archive
    then display the first post as post?
    and will that leave the rest alone (the list described above)
    and will that be cool no matter what the other settings are?
    There are so many posts on this saying that there are so many posts on this, that don’t give the answer, or hints i understand.
    read, read, read, read, shrug, post.

Viewing 6 replies - 1 through 6 (of 6 total)
  • I’d suggest looking at get_posts.

    Cool! It looks like i can add this:

      $posts = get_posts('numberposts=1&offset=1');
      foreach ($posts as $post) :

    • <?php

    just above the archive tags, and pull 1 post from the category to display on the same page.
    very cool.
    thanks! I’ll try that.

    PS: I seem to be a fan of posting lots of code that becomes hard to read with the narrow width here. Sorry.

    everything i have tried seems to break the last line in the archive.php
    here’s a link to the code i am using which displays the posts as a list.
    i’ll go read more on the wiki.

    @kafkaesqui – what a clever service. Really. Thanks.

    This is where i become even more confused than i was with 1.2.
    this note:
    $posts = get_posts('numberposts=3');
    foreach ($posts as $post) :
    makes perfect sense to me.
    However, in 1.3, as you know, we’re divided up into 3 files.
    So what i do to this header, i do to all headers. which kinda sucks.
    i solved a problem tonight with similar issues ($cat=x) by hard coding a header into a page, and removing the require tag for the ordinary head.
    in the end, ryan boran’s plugin was a much better idea.
    and again i’m in over my head.
    learning so slowly…

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘<?php if (is_category()) { ?> function?’ is closed to new replies.