the_excerpt() not working
-
Hi,
I am developing a custom theme for my portfolio. I’m trying to use the_excerpt to display a small description of the post in the thumbnail. I went to Settings > Reading > and switched Full Text for Summary
This enabled my post page to display the excerpt section. Now, in my page-blog.php I have the following code:
<?php get_header( 'blog'); // we only retrieve the post for our blog $arg = array('category_name' => 'Blog'); $category_posts = new WP_Query( $arg ); ?> <?php if ( $category_posts->have_posts() ) : while ( $category_posts->have_posts() ): ?> <div class="blog-posts"> <?php $category_posts->the_post() ?> <?php if (has_post_thumbnail() ): the_post_thumbnail('thumbnail', array( 'class' => 'blog-thumb' )); endif; ?> <h2><a href="<?php the_permalink(); ?>"> <?php the_title()?> </a></h2> <p> <?php the_time('F jS, Y' );?> </p> <p class='entry'> <?php the_excerpt(); ?></p> </div> <?php endwhile; else: ?> <p><?php _e( 'Sorry this page does not exist.' ); ?></p> <?php endif; wp_reset_postdata(); ?> <!-- we close container --> </div> <?php // comments_template(); get_footer(); ?>
I also removed in my functions.php the following filter, since I don’t want the excerpt to be populated with a default <p> tag:
remove_filter( 'the_content', 'wpautop' ); remove_filter( 'the_excerpt', 'wpautop' );
The problem that I’m having is that when the excerpt gets populated on the page, it doesn’t actually limit the word count to 55.
Here is a link
If the excerpt happens to have more than 55 words, they will be added regardless. I’m wondering if there’s something I have been doing wrong? I appreciate the help.Thanks!
- The topic ‘the_excerpt() not working’ is closed to new replies.