Post content not showing

by jrial   Last Updated January 12, 2018 23:08 PM

I have this code that works perfect:

<?php
$temp = $wp_query; $wp_query= null;
$wp_query = new WP_Query(); $wp_query->query('posts_per_page=5' . '&paged='.$paged);
while ($wp_query->have_posts()) : $wp_query->the_post(); ?>

<h2><?php the_title(); ?></h2>
<span><?php the_date('m/d/y'); ?></span>

<a href="<?php the_permalink(); ?>"><button>Read More</button></a>

<?php endwhile; ?>

I want to display an excerpt of the post content between the date and button. So I added <p><?php the_content(); ?></p>. Didn't work. I tried <p><?php get_the_content(); ?></p>. Still nothing.

I tried putting the <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> loop around all of the HTML and just the paragraph. Both yielded nothing.

How do I get the excerpt to display?

Tags : excerpt content


Related Questions



the_content interrupts sidebar

Updated May 27, 2015 01:03 AM

Hide specific content from excerpts

Updated July 05, 2016 08:03 AM