Display most recent post in full, excerpts of older posts

This is the basic idea behind what you want. Extend/Customize to your liking. if ( have_posts() ) : while ( have_posts() ) : the_post(); the_title(); // Incrementing a not instantiated variable results in 1 // so there’s no need to set it to 0 beforehand if ( 0 < $is_first_post++ ) the_excerpt(); else the_content(); endwhile; … Read more

Word Count Function Preventing Permalink Editing

I put the script in a external file // Excerpt word count function excerpt_count_js(){ wp_enqueue_script( ‘excerpt-word-count’, plugins_url( ‘excerpt_word_count.js’, __FILE__ ), array( ‘jquery’ ), false, true ); } And modified the script a bit jQuery(document).ready( function($){ $(“#postexcerpt .handlediv”) .after(“<div style=\”position:absolute;top:2px;right:5px;color:#666;\”><small>Excerpt length: </small><input type=\”text\” value=\”0\” maxlength=\”3\” size=\”3\” id=\”excerpt_counter\” readonly=\”\” style=\”background:#fff;\”> <small>word(s).</small></div>”); $(“#excerpt_counter”).val($(“#excerpt”).val().split(/\S+\b[\s,\.\’-:;]*/).length – 1); $(“#excerpt”).keyup( function() { … Read more

Excerpt unwanted text “”

This little function I created to see what happends when… Outcome here was showing the excerpt as wished when filled out in backend and if left empty it keeps blank. I have no idea why you have filter it that way but that is the way you wish I assume. add_filter( ‘get_the_excerpt’, ‘if_excerpt_left_empty_show_this’ ); function … Read more

Excerpt – add the last few words of posts to the […]

You can achieve this by using the_excerpt filter. You can read further on the codex. Just paste this code in functions.php and set the value of $i = no of words from the end you want. add_filter(‘the_excerpt’,’my_excerpt’); function my_excerpt(){ global $post; $excerpt=get_the_excerpt(); $content = get_the_content(); //gets the whole content $content =strip_tags($content) ; //strips html tags … Read more

How to filter out shortcode when displaying the_excerpt() in the loop?

try this add_filter( ‘get_the_excerpt’, ‘strip_shortcodes’, 20 ); or try this edit echo strip_shortcodes( get_the_excerpt() ); if shortcode is not register with wordpress function add_shortcode add_filter( ‘the_excerpt’, ‘remove_shortcodes_in_excerpt’, 20 ); function remove_shortcodes_in_excerpt( $content){ $content = strip_shortcodes($content); $tagnames = array(‘box’, ‘alert’); // add shortcode tag name [box]content[/box] tagname = box $content = do_shortcodes_in_html_tags( $content, true, $tagnames ); … Read more

Do not show excerpt in post content

Don’t use the more tag to manually define excerpts. There’s a separate input field for that. If it’s not visible, go to “screen options” in the upper right corner of the edit screen to enable it. What exactly is shown on your single and archive pages depends on your theme. There is no general way … Read more

Adding a character counter to the excerpt metabox

Ok, so I didn’t like the way that was written, so i slightly rewrote it with different syntax, and more readable structure. <?php // Add Character Counter to the Excerpt Meta Box function excerpt_count_js(){ if (‘page’ != get_post_type()) { ?> <script> (function($){ $(document).ready(function(){ if ( $(‘#postexcerpt’).length ) { var maxChar = 128; $excerpt = $(‘#excerpt’); … Read more

Auto Populate Excerpt Field

How about using the excerpt_length filter? function my_excerpt_lenght( $length ) { return 15; } add_filter( ‘excerpt_length’, ‘my_excerpt_lenght’, 999 );

the_excerpt – want to modify password protected output

Simple way would be to check output in template (or small wrapper): $excerpt = get_the_excerpt(); if( ‘There is no excerpt because this is a protected post.’ == $excerpt ) { // stuff } else { echo $excerpt; } Another way would be to use gettext filter (which is used inside __()) to catch and modify … Read more