Add a minimum word count to Excerpt (and how to force Excerpt as a rule for WyPiekacz)

Add minimum word count to Excerpt field To enforce a minimum word count for the Excerpt field before the Post status can be changed to pending, we will slightly alter s_ha_dum‘s code. It can be done by filtering wp_insert_post_data: function wcexcerpt($data){ if (!current_user_can(‘edit_others_posts’)) { $num = 5; // minimum word count if (str_word_count($data[‘post_excerpt’]) < $num) … Read more

How do you add a custom excerpt length in twenty eleven child theme?

In your second approach remove <?php the_excerpt(); ?> and replace it with: <?php echo wp_trim_words( get_the_excerpt() , 60); ?> it will show 60 words change to word amount you want. Edit I replaced exact following in content.php: <div class=”entry-content”> <?php the_content( __( ‘Continue reading <span class=”meta-nav”>&rarr;</span>’, ‘twentyeleven’ ) ); ?> <?php wp_link_pages( array( ‘before’ => … Read more

the_excerpt() does not work with has_excerpt()?

excerpt_length is only applied to generated excerpts— excerpts automatically generated from the post body. To trim your manually created excerpt, use the same function that trims the generated one— wp_trim_words. if(has_excerpt()) { $length = apply_filters(‘excerpt_length’,20); echo wp_trim_words(get_the_excerpt(),$length); } else { the_content(); }

Images with excerpt function

For everyone that is looking for an excerpt that keeps images etc in tact without using the first image function, here is the code function pietergoosen_custom_wp_trim_excerpt($text) { global $post; $raw_excerpt = $text; if ( ” == $text ) { $text = get_the_content(”); $text = strip_shortcodes( $text ); $text = apply_filters(‘the_content’, $text); $text = str_replace(‘]]>’, ‘]]&gt;’, … Read more

Edit the excerpt before it is shown

Well, I found it: function get_the_excerpt_filter( $excerpt ) { $wordToRemove = “Introduction”; $len = strlen($wordToRemove); if(substr($excerpt, 0, $len) == $wordToRemove){ $excerpt = trim(substr($excerpt, $len)); } return $excerpt; } add_filter( ‘get_the_excerpt’, ‘get_the_excerpt_filter’ ); Hope this helps someone else.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)