How do I filter the excerpt metabox description in admin?

This description is generated by post_excerpt_meta_box() function and is not passed through any explicit filters. It is however echoed by translation-related _e() function and so passes through gettext filter (which from your question you are already familiar with). As for limiting it to your CPT, I think current post type in admin is held in … Read more

Mandatory excerpt for custom post type

The code adds a filter to wp_insert_post_data: add_filter(‘wp_insert_post_data’, ‘mandatory_excerpt’); And here’s the callback: function mandatory_excerpt($data) { $excerpt = $data[‘post_excerpt’]; if (empty($excerpt)) { if ($data[‘post_status’] === ‘publish’) { add_filter(‘redirect_post_location’, ‘excerpt_error_message_redirect’, ’99’); } $data[‘post_status’] = ‘draft’; } return $data; } The filter callback is passed $data, which as per the Codex includes the following post data: ‘post_author’, … Read more

excerpt in characters

I used this code in one of my last projects: function ng_get_excerpt( $count ){ $permalink = get_permalink( $post->ID ); $excerpt = get_the_content(); $excerpt = strip_tags( $excerpt ); $excerpt = mb_substr( $excerpt, 0, $count ); $excerpt = mb_substr( $excerpt, 0, strripos( $excerpt, ” ” ) ); $excerpt = rtrim( $excerpt, “,.;:- _!$&#” ); $excerpt = $excerpt … Read more

Display Links in Excerpts?

You can use the script I found here: http://aaronrussell.co.uk/legacy/improving-wordpress-the_excerpt/ I’ve modified it to show links in the excerpt, and removed some of the other functions: <?php function keep_my_links($text) { global $post; if ( ” == $text ) { $text = get_the_content(”); $text = apply_filters(‘the_content’, $text); $text = str_replace(‘\]\]\>’, ‘]]&gt;’, $text); $text = preg_replace(‘@<script[^>]*?>.*?</script>@si’, ”, $text); … Read more

Customizing get_the_excerpt() to specific length and “Read More” output.

To get a specific length you can use: wp_trim_words function. It has 3 parameters. Text to trim. Ex: get_the_content() Number of words. Ex: 295 What to append after end of the text. Ex: ” This means null. Use this: <span> <?php echo wp_trim_words( get_the_content(), 295, ” ); ?> <i><a style=”color:#1975D1;float:Right;” class=”title” href=”https://wordpress.stackexchange.com/questions/75069/<?php the_permalink() ?>” rel=”bookmark”>Click … Read more

Remove “Continue Reading” Link From the Teaser Excerpt Only

Change standard text for all excerpts: function custom_excerpt_more($more) { global $post; $more_text=”…”; return ‘… <a href=”‘. get_permalink($post->ID) . ‘”>’ . $more_text . ‘</a>’; } add_filter(‘excerpt_more’, ‘custom_excerpt_more’); Create your own excerpt function: // Rafael Marques Excerpt Function 😉 function rm_excerpt($limit = null, $separator = null) { // Set standard words limit if (is_null($limit)){ $excerpt = explode(‘ … Read more

How to get the unfiltered excerpt, without […] or auto-excerpting

Why don’t you use the global $post variable? It contains an object with the content as it is on the db row corresponding to that post. Here’s how to use it: global $post; // If for some reason it’s readily accessible, invoke it if($post->post_excerpt != ”) { echo($post->post_excerpt); } Or: $my_post = get_post($post_id); if($my_post->post_excerpt != … Read more

How to control manual excerpt length?

Take a look on my answer here: Best Collection of Code for your functions.php file If I understood your question correctly, it does what you are looking for. Place this in functions.php: function excerpt($num) { $limit = $num+1; $excerpt = explode(‘ ‘, get_the_excerpt(), $limit); array_pop($excerpt); $excerpt = implode(” “,$excerpt).”… (<a href=”” .get_permalink($post->ID) .” “>Read more</a>)”; … Read more

How to include line-breaks in the_excerpt?

There is no filter that would allow you to set allowable tags not to be removed by the_excerpt(). Arguably a shortcoming of the core. Anyhow, the actual excerpt generation does not happen in that template tag but entirely elsewhere: Excerpts are generated by the function wp_trim_excerpt(), inside of which the excerpt filters you are already … Read more