Reply To: Breaking news Date

NapitWPTech Theme Support Forums The NewsMag Breaking news Date Reply To: Breaking news Date

#204

Bishal Napit
Keymaster

@webauthor

For displaying the excerpt instead of date in the breaking news section provided via this theme, is going to create design issue and will not look good in the visitors eye. However, if you are ok with that, then, you can try the below PHP code in the functions.php file of the child theme and check:-

function the_newsmag_breaking_news() {
	$get_featured_posts = new WP_Query(array(
		'posts_per_page' => 10,
		'post_type' => 'post',
		'ignore_sticky_posts' => true
	));
	?>
	<ul class="latest-news">
		<?php while ($get_featured_posts->have_posts()):$get_featured_posts->the_post(); ?>
			<li class="latest-news-lists">
				<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">

					<?php if (has_post_thumbnail()) : ?>
						<figure class="featured-image">
							<?php the_post_thumbnail('the-newsmag-featured-small-thumbnail'); ?>
						</figure>
					<?php endif; ?>
					<span class="entry-title"><?php the_title(); ?></span>
					<?php the_excerpt(); ?>
				</a>
			</li>
		<?php endwhile; ?>
	</ul>
	<?php
	// Reset Post Data
	wp_reset_query();
}

You can find the tutorial on creating the WordPress child theme as well as this theme’s sample child theme via this link: https://napitwptech.com/tutorial/wordpress-development/tutorial-creating-wordpress-child-theme/.

Thanks.
Bishal Napit