1. WordPress Snippets

Automatically Add Text to the Post Excerpt

14 / 100 SEO Score

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.
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' );

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.

Comments to: Automatically Add Text to the Post Excerpt

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

Latest Articles

Latest Snippets