How to programmatically bring back “excerpts” field in post editor in WP 3.1+

http://wordpress.org/support/topic/troubleshooting-wordpress-31-master-list?replies=14 a few posts down has instructions for default ‘ON’ options // Change what’s hidden by default add_filter(‘default_hidden_meta_boxes’, ‘be_hidden_meta_boxes’, 10, 2); function be_hidden_meta_boxes($hidden, $screen) { if ( ‘post’ == $screen->base || ‘page’ == $screen->base ) { // removed ‘postcustom’, $hidden = array( ‘slugdiv’, ‘trackbacksdiv’, ‘postexcerpt’, ‘commentstatusdiv’, ‘commentsdiv’, ‘authordiv’, ‘revisionsdiv’ ); } return $hidden; }

How to Remove Checkbox for Excerpt Under Screen Options

You can do this with CSS. .metabox-prefs label[for=”postexcerpt-hide”] { display: none; } In regard to adding the CSS to the admin section, you have two options: Option 1: Add the CSS to a stylesheet and enqueue it using the admin_enqueue_scripts hook. function load_custom_wp_admin_style() { wp_register_style( ‘custom_wp_admin_css’, get_template_directory_uri() . ‘/admin-style.css’, false, ‘1.0.0’ ); wp_enqueue_style( ‘custom_wp_admin_css’ ); … Read more

Thumbnail + Excerpt = loss in word count

For everybody that is looking for a great excerpt that keep html tags in tact and want the excerpt not to cut off mid sentence and have a true word count, here is the code function pietergoosen_custom_wp_trim_excerpt($text) { global $post; $raw_excerpt = $text; if ( ” == $text ) { $text = get_the_content(”); $text = … Read more

How to customize read more link

There are a number of ways this can be achieved, some more complex than others, some offering more functionality than others, however it all depends on your usage-case. For now, the most simple method is to use a combination of, custom fields and a… conditional if/else statement Step 1) In your post edit screen you … Read more

get excerpt without images

Use the_excerpt(); wordpress function to show only text. That function will filter out some html tags such as <img> , <a>. A useful alternative to show only plain text. Note – The the_excerpt() function internally uses get_the_excerpt() to get excerpt and return a new string by filtering tags such as <img>, <a> tags. It also … Read more

How to get the excerpts of all children pages

Firstly, it should be post_excerpt. Secondly, this just stores the manually added excerpt, so it returns empty if you don’t have one. Thirdly, you could setup_postdata: <?php $pagechildren = get_pages( array( ‘child_of’ => $post->ID ) ); ?> <?php foreach ( $pagechildren as $post ) : setup_postdata( $post ); ?> // code <?php endforeach; wp_reset_postdata(); ?> … Read more

get_the_excerpt() not returning anything when post has no excerpt

Double check that you don’t have a check for has_excerpt() that’s hiding the “auto-generated” excerpt. Even if get_the_excerpt() returns something made from post_content, has_excerpt() still returns false if the excerpt is empty. If that’s not the case, see if there’s a function that filters on get_the_excerpt that could be effecting this. To answer your question, … Read more

How to add an admin function only to posts, not pages?

You can use post type conditional tag: if ( ‘post’ == get_post_type() ) Complete: function excerpt_count_js(){ if ( ‘post’ == get_post_type() ) { echo ‘<script>jQuery(document).ready(function(){ jQuery(“#postexcerpt .handlediv”).after(“<div style=\”position:absolute;top:0px;right:5px;color:#666;\”><small>Character limit = 150. Current characters: </small><input type=\”text\” value=\”0\” maxlength=\”3\” size=\”3\” id=\”excerpt_counter\” readonly=\”\” style=\”background:#fff;\”>&nbsp;</div>”); jQuery(“#excerpt_counter”).val(jQuery(“#excerpt”).val().length); jQuery(“#excerpt”).keyup( function() { jQuery(“#excerpt_counter”).val(jQuery(“#excerpt”).val().length); }); });</script>’; } return; } add_action( ‘admin_head-post.php’, ‘excerpt_count_js’); add_action( … Read more

excerpt_length not working

The are two quick ways to display custom excerpt lengths in your theme using wp_trim_words. Remember, if you use the_excerpt(), your excerpt length will always be a maximum of 55, never more. If you use the_content() on the other hand, you can specify an excerpt length of more than 55 words. Use the following to … Read more

the_excerpt Read More Filter

Just add the filter where you need it. Define the filter callback in functions.php but don’t add the filter… // Changing excerpt more function new_excerpt_more($post) { return ‘ <a class=”read_more” href=”‘. get_permalink($post->ID) . ‘”>’ . ‘read more’ . ‘</a>’; } In your template file just before you need the custom more link: add_filter(‘excerpt_more’, ‘new_excerpt_more’); And … Read more