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

How to remove “Read on” content in the_excerpt?

If you’re using the Twenty Eleven theme I think you need to remove that theme’s filter before you can define your own: remove_filter( ‘excerpt_more’, ‘twentyeleven_auto_excerpt_more’ ); edit building from t-p try this: add_action( ‘after_setup_theme’, ‘my_child_theme_setup’ ); function my_child_theme_setup() { remove_filter( ‘excerpt_more’, ‘twentyten_auto_excerpt_more’ ); } In case you are using twentyeleven, use “twentyeleven_auto_excerpt_more” instead of ‘twentyten_auto_excerpt_more’

get_the_excerpt() with fallback like the_excerpt()

The function the_excerpt() is only a echo of the function get_the_excerpt(): function the_excerpt() { echo apply_filters(‘the_excerpt’, get_the_excerpt()); } If you like a fall back for no input the excerpt meta box, then create a text from the content – get_the_content(). You can use the core function wp_trim_words() for set the counter for words and easy … Read more