Display article date on single.php

I have set up a news page using a plugin, and the full article reads and displays on the single.php page.

The date just doesn’t echo out using the code below:

<?php if ( $startright_layout_blog_listing_sidebar == 'left' ) { ?>
<div class="col-lg-9 col-md-9 col-md-push-3 col-lg-push-3 right-content">
       <?php echo the_date(); ?>
<?php get_template_part( 'template-parts/content', 'single' ); ?>
</div>
<div class="col-lg-3 col-md-3 col-md-pull-9 col-lg-pull-9">
<?php get_sidebar(); ?>
</div>

It doesn’t work in that position, but if I move the echo date line to beneath the line below it it echo’s out, but its at the bottom of the page beneath the article, and so in the wrong place.

Hey @multichild,

So if you move it below the call to get_template_part() then it works OK? If that’s so, it sounds like maybe that template fetches the data for the news item or something… have you checked out what’s going on in that file?

1 Like

Hey fretburner,

Ye that’s correct, and ye this is what I thought, but didnt know where to look to find whats going inside there.

Would it be in the main functions.php file

Aha, I think I have found it.

Does this look about right

<?php
/**
 * @package startright
 */
$startright_layout_blog_listing_featured_img = '';
$startright_layout_blog_listing_featured_img = startright_get_option( 'startright_layout_blog_listing_featured_img' );
?>
<div id="primary" class="content-area">
	<main id="main" class="site-main">
		<?php while ( have_posts() ) : the_post(); ?>
			<article id="post-<?php the_ID(); ?>" <?php post_class( 'startright-single-post' ); ?>>
			<?php if ( has_post_thumbnail() ) {
    			the_post_thumbnail('ccfw-blog-featured-top');
			} ?>
				<?php echo startright_blog_single_item(); ?>
			</article><!-- #post-## -->
			<?php
			// If comments are open or we have at least one comment, load up the comment template
			if ( comments_open() || get_comments_number() ) :
				comments_template();
			endif;
			?>
		<?php endwhile; // end of the loop. ?>
	</main><!-- #main -->
</div><!-- #primary -->

I’m guessing that the first argument is part of a path, so look out for a folder called template-parts somewhere in your project.

lol, thanks fretburner, Ive got it.

You one sentence pointed me in the right direction, and bingo it worked.

Thanks again mate

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.