The Must Have for WordPress
The Must Have for WordPress
×
  • Home
December 5, 2019
WordPress

Customize or Modify the WordPress Post Excerpt

by Martin Jost
No comments
1 min Reading Time
905 Views
5 Score
5 Likes
Share on Facebook Tweet on Twitter Share on Linkedin Pin on Pinterest Send via E-Mail Send via WhatsApp

WordPress comes with own functions, such as get_the_excerpt() or the_excerpt(), to output a short version of the post content. This short description can be entered individually for each post.

How can I change the length of the excerpt?

A short description may be slightly longer or shorter depending on the post. If the post excerpt is used in post lists, it makes sense to adjust content length of the excerpt. In this case we can use the WordPress filter excerpt_length.

To do this, add the following code snippet to the functions.php of your WordPress theme:

How can I extend or customize the excerpt?

If you want to append a suffix to the post excerpt, for example, we can use the WordPress filter excerpt_more. This is useful if we want to end our post excerpt with a suffix like “…” or we want to insert a “Read more” button at the end of the text.

For example, add the following code snippet to your theme’s functions.php file, to append the shortened post excerpt with “…”:

Or use the following code snippets to include a read more button:

With these two WordPress filters, the post excerpt can be easily customized and extended.

Last updated: December 5, 2019

Customize or Modify the WordPress Post Excerpt Score: 5 / 5 (3votes)
Share on Facebook Tweet on Twitter Share on Linkedin Pin on Pinterest Send via E-Mail Send via WhatsApp
Theme
The Author
Published by
Martin Jost

View all posts by Martin Jost

Related Posts
O
WordPress Open Graph in WordPress einbetten, ohne Plugin

Das Open Graph-Protokoll ermöglicht es, dass jede Webseite als “rich object” im &#82 ...

Read More
C
PHP Convert HEX color to RGBA color code in PHP

While working with theme or plugin options, in some cases we need to convert a hex (hexadecimal) ...

Read More
M
Javascript Minify and compress Javascript files in PHP

Loading time is an important factor in search engine optimization and for the user experience. E ...

Read More
Read more
L
Previous Post
Load WooCommerce Templates from Plugin files
C
Next Post
Customize the default WordPress Image Compression
Leave a Reply Cancel reply

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

  • Imprint
  • Privacy Policy
© 2016-2023 - wphave - The Must Have for WordPress
Login

Lost your password?

RequiredEssential cookies enable basic functions and are necessary for the proper functioning of the website.
  • Name: Cookie Status
  • Provider: Owner of this website
  • Purpose: Is necessary to check whether the user's web browser allows cookies.
  • Privacy Policy: https://wphave.com/privacy-policy/
  • Cookie Name(s): cookie_status
  • Duration: 1 Minute
  • Name: Cookie Consent
  • Provider: Owner of this website
  • Purpose: Is necessary to check whether the user agrees to allow opt-in cookies or not.
  • Privacy Policy: https://wphave.com/privacy-policy/
  • Cookie Name(s): cookieconsent_analytics, cookieconsent_marketing, cookieconsent_status
  • Duration: 1 Year
  • Name: Like Button
  • Provider: Owner of this website
  • Purpose: Is necessary to check whether the user has already gave a like for a specific post.
  • Privacy Policy: https://wphave.com/privacy-policy/
  • Cookie Name(s): like_btn_{POST_ID}
  • Duration: 21 Days
  • Name: Post Rating
  • Provider: Owner of this website
  • Purpose: Is necessary to check whether the user has already rate a specific post.
  • Privacy Policy: https://wphave.com/privacy-policy/
  • Cookie Name(s): rating_{POST_ID}
  • Duration: 7 Days
AnalyticsStatistics cookies collect information anonymously. This information helps us to understand how our visitors use our website.
  • Name: Google Analytics
  • Provider: Google LLC
  • Purpose: Google cookie for website analysis. Generates statistical data on how the visitor uses the website.
  • Privacy Policy: https://policies.google.com/privacy
  • Cookie Name(s): _ga, _gat, _gid
  • Duration: 2 Years