• I’m using category.php to display my posts, but the post excerpt does not display. I try to create a custom loop in page template and it work normal. Here’s my code:

    <div class="posts">
    	<?php while(have_posts()) : the_post(); ?>
    	<div class="post">
    		<a>" class="thumb">
    			<?php the_post_thumbnail() ?>
    		</a>
    		<div class="post-info">
    			<h3 class="post-name">
    				<a>"><?php the_title() ?></a>
    			</h3>
    			<div class="meta"><div class="cats"><?php the_category('/') ?></div> - <time data="<?php the_time('d m Y') ?>"><?php the_time('d M, Y') ?></time></div>
    			<p><?php echo get_the_excerpt() ?></p>
    		</div>
    	</div>
    	<?php endwhile; ?>
    	<?php wp_pagenavi();wp_reset_query(); ?>
    </div>
    • This topic was modified 5 years, 4 months ago by webkitvn.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi,

    get_the_excerpt filter hook may be emptying it.

    But please disable LiteSpeed Cache plugin first.

    Thread Starter webkitvn

    (@webkitvn)

    I disabled Litespeed Cache but nothing change.
    I create a custom query and it works normally

    <?php 
    	$query = new WP_Query(array(
    		'post_type' => 'post',
    		'posts_per_page' => '4'
    	));
    	while($query->have_posts()) : $query->the_post();
    ?>
    	<div class="col-12 col-sm-12 col-md-6 col-lg-3">
    		<a href="<?php the_permalink() ?>" class="post">
    			<?php the_post_thumbnail() ?>
    			<h4><?php the_title() ?></h4>
    			<p><?php echo get_the_excerpt() ?></p>
    		</a>
    	</div>
    <?php endwhile; ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Nothing appears using get_the_excerpt() in category.php’ is closed to new replies.