Skip links

Automatically Add Text to the Post Excerpt

sometimes we need to add default text as post excerpt where you can view in post dashboard or frontend now use the plugin to do that or add simply code on WordPress function.php file.

This code snippet will let you filter excerpt filed by WordPress built-in hook default_excerpt

Steps to register widget area on WordPress:

  1. Open WordPress admin panel then go to Appearance > Theme Editor
  2. Open theme functions.php file, if you work localhost open the same file using any code editor IDE
  3. Add the following code at the bottom of the file.
  4. Save the changes and add new post.

[php]
function zytheme_excerpt_content( $content ) {
$content = "This Text will add automatically when add new post";// Change This Text As You Need
return $content;
}
add_filter( ‘default_excerpt’, ‘zytheme_excerpt_content’ );
[/php]

Did you find the WordPress snippets in this article helpful? Share it with your friends and if you have any questions and want to ask us about it, please don’t hesitate to add comment.

Leave a comment

Explore
Drag