Forums

Querying for category daily archives (3 posts)

  1. Vicky Arulsingam
    Member
    Posted 7 years ago #

    I've created a custom page to display list of daily archives for a particular category

    <?php query_posts('cat='.$cat.'&posts_per_page=-1'); ?>

    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    <?php the_date('','<small>','</small>
    '); ?>

    <?php endwhile; ?>
    <?php endif; ?>

    The problem I'm having is when I try to add links:

    '< a href = domain.com /<?php the_date('Ymd')?>.php"> <?php the_date('','<small>','</small>
    '); ?>'

    What shows up in html code is:
    < a href="http://www.mydomain.com/content/20050421.php"></ a>

    < a href="http://www.mydomain.com/content/.php">

    The dates don't show up at all.

    Can anyone help me figure out what I'm doing wrong?

  2. Kafkaesqui
    Moderator
    Posted 7 years ago #

    the_date() only displays/returns the first time it's called (for a day). See the info on it here:

    http://codex.wordpress.org/Template_Tags/the_date

    You can use the_time() in its place with a date formatting string:

    http://codex.wordpress.org/Template_Tags/the_time

  3. Vicky Arulsingam
    Member
    Posted 7 years ago #

    Thank you! It worked like a charm.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.