WordPress.org

Ready to get started?Download WordPress

Forums

<?php if (is_category()) { ?> function? (7 posts)

  1. dss
    Member
    Posted 10 years ago #

    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.

  2. Kafkaesqui

    Posted 10 years ago #

    I'd suggest looking at get_posts.

  3. dss
    Member
    Posted 10 years ago #

    Cool! It looks like i can add this:

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

    • <?php
      endforeach;
      ?>

    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.

  4. Michael Adams (mdawaffe)
    Member
    Posted 10 years ago #

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

  5. dss
    Member
    Posted 10 years ago #

    hrm...
    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.
    F.

  6. Michael Adams (mdawaffe)
    Member
    Posted 10 years ago #

    @Kafkaesqui - what a clever service. Really. Thanks.

  7. dss
    Member
    Posted 10 years ago #

    This is where i become even more confused than i was with 1.2.
    this note:
    <?php
    $posts = get_posts('numberposts=3');
    foreach ($posts as $post) :
    start_wp();
    ?>
    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...

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.