hello,
you can try the following 🙂
<?php the_date(get_option(‘date_format); ?>
this way, when you go to the settings in the dashboard and u change how the date is display in the front end.
hope that solved your problem.
Thread Starter
1db
(@1db)
Nope, that killed the page.
ha, sorry
missing a ‘
<?php the_date(get_option(‘date_format'); ?>
-
This reply was modified 5 years, 7 months ago by Benjamin Lu.
@benlumia007
also missing a closing bracket:
<?php the_date(get_option('date_format')); ?>
yeah, my bad,
did that fix what you wanted.
Thread Starter
1db
(@1db)
No, it didn’t. The month is still November, the year is still -0001.
Let me give a bit more info. Here is a larger snippet of that page:
<?php if (have_posts() ) : ?>
<?php if (is_category() ) { ?>
<h3 class="categoryHead"><?php single_cat_title(); ?></h3>
<?php } elseif (is_month() ) { ?>
<h3 class="categoryHead"><span>Browsing posts from</span> <?php the_time('F, Y'); ?></h3>
<?php } ?>
<?php while (have_posts() ) : the_post(); ?>
<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<div class="meta">
<p><?php the_time('F j, Y') ?> | Posted in <span><?php the_category(', ') ?></p>
</div>
Notice that the_time is used twice. One works (the one in div.meta), and one does not. They’re both inside the loop. What gives?
-
This reply was modified 5 years, 7 months ago by 1db.
the not working one is outside the loop;
(the loop actually starts with ‘while’ and ‘the_time()’ needs ‘the_post()’ to be setup properly)
https://codex.wordpress.org/Function_Reference/the_time
Thread Starter
1db
(@1db)
If I simply move <?php while (have_posts() ) : the_post(); ?>
above the category/month if statements, then the headline will print above each post in the archive list. How is it possible to make this work?
Edit: use rewind_posts. Thanks, Michael, I’ve got it working now.
-
This reply was modified 5 years, 7 months ago by 1db.