0

i try show the_date with link to same date!

 <?php the_date('l j F Y', '<tr>
 <th colspan="3"><a href="<?php the_date('Y/m/d'); ?>" rel="bookmark">', '</th>
 </tr>'); ?>
  • are you doing that inside The Loop? – Ignat B. Sep 6 '15 at 22:40
  • yes.inside The Loop – Horby Sep 9 '15 at 12:07
1

Try this:

<?php 
$archive_year  = get_the_time('Y'); 
$archive_month = get_the_time('m'); 
$archive_day   = get_the_time('d'); 
?>
<a href="<?php echo get_day_link( $archive_year, $archive_month, $archive_day); ?>"><?php the_date('Y/m/d'); ?></a>

HTML result:

<a href="http://example.com/2015/09/07">2015/09/07</a>
1
<?php 
$archive_year  = get_the_time('Y'); 
$archive_month = get_the_time('m'); 
$archive_day   = get_the_time('d'); 
?>
<a href="<?php echo get_day_link( $archive_year, $archive_month, $archive_day); ?>"><?php the_date('Y/m/d'); ?></a>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>

HTML result:

<a href="http://example.com/2015/09/07">2015/09/07</a>
<a href="http://example.com/title-post">Title Post</a>

For example, if you want show the latest posts:

global $post;
$post_args = array(
    'posts_per_page' => 5
);
$the_query = new WP_Query( $post_args );

if ( $the_query->have_posts() ) {
    while ( $the_query->have_posts() ) {
        $the_query->the_post();
        $archive_year  = get_the_time('Y'); 
        $archive_month = get_the_time('m'); 
        $archive_day   = get_the_time('d'); 
    ?>
        <a href="<?php echo get_day_link( $archive_year, $archive_month, $archive_day); ?>"><?php the_date('Y/m/d'); ?></a>
        <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    }
wp_reset_query();
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.