Show Publish date on Archive Page (WordPress Theme Tutorial)

A WordPress OnePress Theme User needs to show publish date on the archive page. So I wrote this tutorial to help him.

What’s the Problem?

Hi,

How can I display the post published date for every post on the post archive page?

The theme by default shows the published post date on single-post pages but it does not offer an option to do so on the archive page as well.

Is there an option I missed out? If not, can you provide some script/snippet to do so?

Regards,

Chris

How to Show Publish date on Archive Page?

According to his question, we need to do some modifications to the theme.

How to Show Publish date on Archive Page

In the OnePress Theme, go to "template-parts" folder and open the file "content-list.php"

Search for this line

<header class="entry-header">
			<?php the_title( sprintf( '<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' ); ?>
		</header>

Replace it with this code:

<header class="entry-header">
			<?php the_title( sprintf( '<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' ); ?>
		</header>
		<div class="entry-meta">
			<?php onepress_posted_on(); ?>
		</div>

Now, you are good to go.

Please note that modifying the code requires caution. Always make a backup of your theme and site before making changes. The best way to check them is by testing them on the staging site(s) and if you have a third-party plugin, consider plugin conflicts as well.

I hope it helps
Best Regards