WordPress.org

Ready to get started?Download WordPress

Forums

Alternative archive formats (7 posts)

  1. hj
    Member
    Posted 4 years ago #

    Hi,

    My theme (Z-Herald) displays post archives as full, complete posts, in chronological order. I can see the archives page getting rather long.... ;)

    I'd like to show the most recent three (or five) posts in full, and then list older entries by title only, the title being a link to the full post.

    I can't write code, so is there a widget or something that will do this for me. Note this is NOT a sidebar issue, this is the full archive display when you click on any post category.

    thanks
    Hugh

  2. MichaelH
    Member
    Posted 4 years ago #

    Okay as an example, switch to the WordPress Default theme, then edit the wp-content/themes/default/archive.php template:

    Change

    <?php while (have_posts()) : the_post(); ?>

    to

    <?php
    $count=0;
    while (have_posts()) : the_post(); ?>

    and change

    <?php the_content() ?>

    to

    <?php
    $count++;
    if ( $count < 4 ) {
    the_content();
    }
    ?>

    Related:
    Stepping Into Template Tags
    Stepping Into Templates
    Template Hierarchy

  3. hj
    Member
    Posted 4 years ago #

    Hi Michael,

    I think I could do that....except I don't want to use the default WordPress archive. Do I?...???

    Do you mean replace my theme archive file with the default one, amended as you suggest?

  4. hj
    Member
    Posted 4 years ago #

    OK, well I took the plunge and replaced the theme's archive.php with your amended default archive.php.

    Nice! I got my four full stories and then just the title and date for the next one.

    I think the older ones (5 onwards) need a different font and size though, they look a bit daft with their h3 font and nothing else - I could do with all the title links being in a 12pt verdana or something.

    So thanks, it worked technically perfect..but how do I style the two sides of the equation?

    cheers
    Hugh

  5. MichaelH
    Member
    Posted 4 years ago #

    See CSS

  6. hj
    Member
    Posted 4 years ago #

    Yes I know the fundamentals of CSS, but how would you add a css class into the code you just showed me?...that's what I don't know (and css won't tell me)

  7. MichaelH
    Member
    Posted 4 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic