What about using this function in functions.php:
function new_excerpt_length($length) {
return 20;
}
add_filter('excerpt_length', 'new_excerpt_length');
And then getting it by adding<?php the_excerpt()?>
to php template?
OR:
<?php $string = get_the_excerpt(); if (strlen($string) <=20) {echo '' . $string . '';} else {echo '' . substr($string, 0, 20) . '...';}?>
In this case 20 is characters
Related Posts:
- How to add an admin function only to posts, not pages?
- How do I display some posts fully on the homepage, and some as an excerpt only?
- The_excerpt() doesn’t parse – how to change that?
- Trim excerpt to first paragraph
- wp trim function not working
- Format latest/newest post differently
- is_page Funtion for Posts ?
- Post type no single page
- Displaying post excerpt using wpdb query
- Get post meta retrieving wrong value
- Adding a user’s ID behind the tag ref link address
- How to disable the_excerpt from one post
- Trying to edit archive.php to only show post extract, with featured image
- How to only publish posts with image in it
- Isn’t the way posts are displayed very unefficient?
- Add custom text automatically on each post
- How to check in functions.php if there is data in a WP_Query?
- Show metabox value last post excerpt, title and link
- Hook for changing excerpt content when excerpt not set
- restrict incrementation of post vies count when refreshing the page
- Defined function isn’t showed on page
- Change the number of excerpts displayed in search results layout
- WordPress 302 Redirect to Random Product/Post/Page
- the_excerpt is displaying excerpts of every post
- Getting Whitescreen when publishing a post [closed]
- Using system date format
- Get post by tag
- Add code to a specific post’s content
- Related Posts function not working
- the_content() Not Grabbing All Content
- Un-highlight Blog Menu Item when Category Menu Item is Selected
- Why excerpt is Displaying same in Random Posts list
- Is it advisable to use $post->comment_count instead of get_comments_number( $post_id )
- Related Posts: Changing Function For Posts Per Page
- Query function not executed between element [closed]
- Optimize CPT-function with a loop
- content summary of a post disappears If an images added at the beginning of the post. how to solve it?
- saving/reading custom field value does not work – no value gets POSTed
- Same post appears in related Posts?
- Internal linking to posts permalink fail because of spaces and stripe at postname
- Have h2 tag not show up if there are no blog posts
- WordPress as CMS: How to manage/handle images assigned to a post as full-sized background images in a slideshow?
- Making a wordpress page print friendly
- WordPress Excerpt Paragraph Limiting
- Grab value of excerpt_length
- Calling Permalinks With PHP
- Help on conditional statement to accompany wp_insert_post function please?
- How to implement a WordPress comments function?
- How to add content above footer in posts from specific category
- Set Default Post as Parent Child (Nested) Relation
- I need to create “View Profile” and “Edit Profile” links by incorporating the Post Title/ID, but can’t seem to manage it
- How to Remove HTML Elements from Post Excerpt?
- How to add text before post_excerpt in Gutenberg
- how to show comments only author which send own posts in wordpress
- get category in list of posts // shortcode for custom related posts
- shortcode // get posts by ids
- Why is WordPress showing a blank excerpt for just one of my posts?
- How to put the author of the post in the comments?
- Check if almost 10 year old – working code is up to date
- Alt text attributes not showing over portfolio images
- Related post not showing table of content
- How to limit wordpress the_excerpt() dynamically
- Find most used words in post titles
- WordPress Sticky Post Count “Fix” Breaking Pagecount by 72 pages!
- $post->post_content empty while all other properties are correct
- Function is printing twice – any suggestions?
- How to add a custom class attribute into code wrapper? [duplicate]
- Remove pagination if search returns empty
- Remove HTML tags from all posts
- Set a post expiration and delete a post when expirate
- Moved a website and excerpts don’t work for old posts
- I want to change the WordPress comments file
- Enable HTML Tags in WordPress Post excerpt
- Replace Tag Keyword With Link Within Post Content
- Excluding tag Link from html tags in Post content
- Save All Post Permalink From A Specific Category into a .txt file
- Changing a users posts to drafts upon role change
- AJAX load more posts not using correct category and repeating the same few posts
- How to Display Most View Post in the template file?
- Get post id outside loop : Notice: Trying to get property of non-object
- How to display post excerpt beside post list inside Post of Dashboard
- Show post excerpt
- How do I apply a wordpress function to something with no ID inside an archive page?
- Show all posts from the tags without having to set all of them
- Show author bio box
- How to correctly escape data
- Display author bio box
- Check if user has avatar
- Nothing appears using get_the_excerpt() in category.php
- im trying make a function to auto correct posts when i open the posts in the backoffice
- How to change number of posts shown on homepage vs other pages?
- Show only top 3 posts from 3 categories in order on home page
- Post List Widget with custom posts and editing the Read More Link
- Call image from post on index page?
- How to edit label_submit styling?
- How do I get thumbnails?
- Run function after post is updated
- Show category post with excerpt text
- How to get posts from network blog
- When Author add new post change default status to pending