How to show post excerpt in wordpress?
There are two ways to show post excerpt in WordPress. I will show you here.
First method:
First add this code in functions.php
function new_excerpt_more( $more ) { return ' <a class="read-more" href="'. get_permalink( get_the_ID() ) . '">' . __('Read More', 'your-text-domain') . '</a>'; } add_filter( 'excerpt_more', 'new_excerpt_more' );
then add this code in the loop and single.php
the_excerpt();
You can show featured images too, just add the_post_thumbnail();
Another Method:
First add these codes in functions.php just like first methods.
function get_excerpt($count){ $permalink = get_permalink($post-&gt;ID); $excerpt = get_the_content(); $excerpt = strip_tags($excerpt); $excerpt = substr($excerpt, 0, $count); $excerpt = substr($excerpt, 0, strripos($excerpt, " ")); $excerpt = $excerpt.'... <a href="'.$permalink.'">more</a>'; return $excerpt; }
Then add get_excerpt(125); in your themes loop and single.php
Done !