How to Display the post excerpt in WordPress without plugin

How to Display the post excerpt in WordPress without plugin
How to Display the post excerpt in WordPress without plugin

Basically, when we visit some websites then we see some website use post excerpt in the Recent post. If you want to display the post excerpt to your website.  you can use some plugin but today I will show how to display post excerpt to your  WordPress website without Plugin.

 

Usually, have two types of   Post excerpt  Such as Post excerpt by word and excerpt by character. I will show you the excerpt by character.
At first paste this below code in the function.php and  click save.
<?php



function excerpt($limit) { $excerpt = explode(' ', get_the_excerpt(), $limit); if (count($excerpt)>=$limit) { array_pop($excerpt); $excerpt = implode(" ",$excerpt).'...'; } else { $excerpt = implode(" ",$excerpt); }  $excerpt = preg_replace('`[[^]]*]`','',$excerpt); $excerpt = $excerpt.'... <a href="'.get_permalink().'">'; return $excerpt;; }
	
	
function content($limit) { $content = explode(' ', get_the_content(), $limit); if (count($content)>=$limit) { array_pop($content); $content = implode(" ",$content).'...'; } else { $content = implode(" ",$content); }     $content = preg_replace('/[.+]/','', $content); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]&gt;', $content); return $content; }
	
	

	?>

Finally, The final steps now . just paste this below code where you want to show excerpt this post.but keep mind in the first   (30) how much digits put inside then the number of digits character showing post excerpt.

<?php  echo excerpt(30);?> <a href="<?php the_permalink() ?>"> [Read More] </a>

 

 

Thanks  for reading this post . If you like this post please hits subscribe button our YouTube channel .

 

[sm-youtube-subscribe]

Leave a Reply

Your email address will not be published. Required fields are marked *

Press ESC to close