• I posted the following in the “How-To and Troubleshooting” section without much luck. Hopefully someone here can point me in the right direction…

    Is it possible to display the date, title and excerpt of a post on an archives page?

    I would like to develop a “newsroom” listing page that lists the posts (right now categorized as “news”) in the format “2005.03.04 – Title of Post Here – Excerpt Here”. The date/title will be enclosed in a link to the specific post. When the user clicks on the link they will see that specific post.

    So far I can list all of the posts I need. The only problem is only the date shows up. Is there a trick to using <?php wp_get_archives(‘type=postbypost’); ?> that I need to know?

    Am I trying to tackle this the wrong way?

    Thanks in advance for any help!

Viewing 8 replies - 1 through 8 (of 8 total)
  • I think you’re going about this the wrong way. wp_get_archives(); can only output lists of titles and dates and stuff like that — it can’t output excerpts like you want it to without going in and hacking the core code itself. You can probably accomplish what you want easily with a new Page template. Maybe:

    <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_time('Y.m.d'); ?></a> -- <?php the_title(); ?> -- <?php the_excerpt(); ?>

    Thread Starter pelias

    (@pelias)

    Avenir — Thank you for your quick reply. I is much appreciated!

    Did you want me to add that code to the “page.php” in “/WP/themes/theme/page.php? Or place the code in a new “Page” within WordPress?

    I have a few other pages in the system so I am hesitant to edit “page.php”. I did place the code into the new page I created (via WP) and was not able to get any output.

    actually, create a separate archive.php and add that code. That way when an archive page is called it will use that template. If you dont want to create a separate file, use an if statement, ie:

    <?php /* If broswing a monthly archive page */ if ( is_month() || is_page() ) { ?>
    <?php the_excerpt ?> or whatever you want to display
    <?php } ?>

    you can browse the codex for other ways to implement conditionals.

    https://codex.www.ads-software.com/Conditional_Tags

    Thread Starter pelias

    (@pelias)

    omanno – thank you for the help.

    There has to be something really simple that I am not grasping here because when I edit a copy of the “archive.php” (named archive-news.php) and select it as the template page I can’t get more than the date and page title displayed — not the info from the posts in the system (all newsroom items).

    I have a category called “news” setup as well as an archive page called “newsroom”. If I go to “website.com/content/news/” the category listing shows perfectly but only shows one post at a time. No biggie. When I try “website.com/content/newsroom/” (the page setup in WP with the archive-news template page) I am unable to get the info to display.

    My “archives-new.php” file contains:
    <?php
    /*
    Template Name: Archives - News
    */
    ?>

    <?php get_header(); ?>

    <h1><span class="blue">New Day Trust</span> Newsroom</h1>

    <div class="contentListing">
    <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_time('Y.m.d'); ?></a> -- <?php the_title(); ?> -- <?php the_excerpt(); ?>
    </div>

    <?php get_footer(); ?>

    I guess you have to put that stuff in The Loop; see this

    Thread Starter pelias

    (@pelias)

    moshu — thanks for the tip. However i did that in another version of the template with no luck. doing so just lists the date then nothing else. the_title(); just returns “newsroom” not the title of the post (returns the title of the page).

    I am going to try and hack a version of wp_get_archives(); so see if that is the best way to go about this. I can’t seem to get things to loop right. super frustrating I tell ya.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Customizing wp_get_archives() output’ is closed to new replies.