• Ok, I’ve seriously searched everywhere for this. And I’ve gotten somewhere close to what I want.
    What I would like to do is to be capable of going into:
    blah.com/2005
    and seeing something like this:

    Archive for 2005

    • August
    • Category: Post 1
    • Category: Post 2
    • Category: Post 3
    • July
    • Category: Post 4

    You get the idea. Something along the lines of: https://blindmuse.com/blog/2004/
    And still be able to exclude a certain category from these archives.

    Any ideas?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter realitym

    (@realitym)

    Ok. I’ve gotten something so far, that looks like this:

    • August 2005
    • Post 1 (in august)
    • Post 2 (in august)
    • Post 3 (in august)
    • Post 4 (from july)

    I’ve gotten to it by finding some Nicer Archives hack and modifying it a bit and made it a Plugin, the code of which can be found: https://pastebin.com/336747

    And by adding the following in my date.php template (obviously after the if is_year part:
    <?php
    if ($posts) {
    print '<ul>';
    $prevDays = array();
    foreach ($posts as $post) { start_wp();
    $day = " "; //get_day_nice(the_time("d", false));
    $year = get_archive_header('<li class="arch-year">', '</li>');
    $output = '';
    if ($prevDay != $day) {
    if ($prevDay) { $output .= "</ul></li>"; }
    $output .= $year;
    // $output .= '<li class="arch-day">';
    $output .= '<ul class="arch-post">';
    }
    print $output;
    print '<li class="arch-post"><a href="'. get_permalink() .'" rel="bookmark" title="'; the_title(); print'">'; the_title(); print '</a></li>';
    $prevDay = $day;
    }
    print "</ul></li>";
    print '</ul>';
    } else { // end foreach, end if any posts ?>
    Nothing to show here.
    <?php } ?>

    So, any ideas from there? Or something totally different that’ll get me what I want?

    BTW: I have no idea where I got the code from… I’d love to give credit to whoever wrote it, but as I’ve been downloading things here and there… well, you get the point. So, if it’s yours please do say.

    Here’s a *quick* example using query_posts() that would do what you’re after:

    https://pastebin.com/336763

    However, it may be overly database query-happy; the number of queries it generates to the database is far more than I’d prefer to see on a single page.

    Thread Starter realitym

    (@realitym)

    Thank you, it was just what I was looking for.
    I just added the get_the_category() and it did what I was looking for.

    About the queries, it does make some intense jumps on it, but I don’t expect it to be a highly visited page on the site, since there are hardly any links pointing to it. But should someone stumble upon it, I wanted them to find a nice looking page. ??

    Let’s hope someone comes up for a more query-friendly solution in the future.

    Once again, thank you so much.

    Hey, I’m looking to do something very similar. I’d like something like this in my navigation column on a catagory page:

    YEAR
    -subcategoryA
    -subcategoryB
    -subcategoryC
    YEAR
    -subcategoryA
    -subcategoryD

    If there’s no posts in categoryX for a specific year, then it would not show up on the list.

    Possible? I’m not a programmer, but I’m resourceful. If anyone can give me clear instructions, I can implement it.

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Show only Months and Titles in Year Archive’ is closed to new replies.