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
- GET the excerpt by ID
- How to change the case of all post titles to “Title Case”
- Function to execute when a post is moved to trash .
- Fatal error: Call to undefined function post_exists()
- Code to auto expire posts after 30 days
- List only child categories a post is in, of a specific parent category
- How to change post status from publish to draft using hook in wordpress?
- Custom colors for post rows based on post meta value
- How to Display Post View Count
- Remove double space after a period
- Why does `url_to_postid` return 0 when testing `page_for_posts` Page?
- Delete Post From Front-End and attachment permanently
- Limit function to specific post category
- How to link up “read more” on excerpts hack from WP Recipies
- When paginating a Page with the tag, how can the 2nd and subsequent page styles be customised?
- Append Text to $post->post_excerpt
- How to show a full post, not just an excerpt
- Function to show random posts from a category
- Hiding posts in a list from specified categories
- Get post excerpt and title by specific post ID?
- Checking is user author of number of posts?
- Display most recent post in full, excerpts of older posts
- Create cron job without a plugin?
- Modify WP_Post before processing
- How to rename “Publish” metabox title in post screen
- Action hook for new pending posts?
- Uppercase first sentence in every post
- Add icon/badge next to posttitle of specific category
- Ajax posts filter by date, comments, top views, top likes
- Converting a dynamic piece of code using WordPress Loop into a static one using Post ID
- Why content_arr[‘extended’] removes paragraph tags?
- Force the “Choose from the most used tags” meta box section to always be expanded
- Show the content that is after the excerpt using child theme
- How to allow users to post only in certain category and hide elements from edit page?
- Display post x of y within category
- WordPress Automatic Filename Changer
- Order posts alphabetically: how to set order=asc in mysql query?
- Post type no single page
- Displaying post excerpt using wpdb query
- Adding a user’s ID behind the tag ref link address
- How to disable the_excerpt from one post
- How to check in functions.php if there is data in a WP_Query?
- Show metabox value last post excerpt, title and link
- 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]
- Get post by tag
- Add code to a specific post’s content
- Why excerpt is Displaying same in Random Posts list
- Related Posts: Changing Function For Posts Per Page
- Query function not executed between element [closed]
- Optimize CPT-function with a loop
- 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
- Calling Permalinks With PHP
- 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
- 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
- How to limit wordpress the_excerpt() dynamically
- WordPress Sticky Post Count “Fix” Breaking Pagecount by 72 pages!
- 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
- I want to change the WordPress comments file
- 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
- How to Display Most View Post in the template file?
- 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
- Display author bio box
- Check if user has avatar
- Nothing appears using get_the_excerpt() in category.php
- Call image from post on index page?
- How to edit label_submit styling?
- How do I get thumbnails?
- Run function after post is updated
- When Author add new post change default status to pending
- fire action when post is being edited as well as saved?
- How to limit the number of results for all query_posts on mysite
- User driven content problems
- How can i show only 30% of the “the_content(“More…”)”?
- Notify Author of the post if admin deletes his post and perform some function
- How do we display a certain category type on a page while hiding all others?
- What function does the loop of displaying posts?
- Show Next/Previous without Link
- Filters do not work when there are multiple (one works)
- How to use shortcode to get the second to newest post?