Custom excerpt function re-factoring

I’d simply set a flag as second input argument for the function: function new_wp_trim_excerpt( $text, $case=”plain” ) { switch ( $case ) { default : case ‘plain’ : // do stuff – your function so far break; case ‘image’ : break; } } Notes: Avoid names like class=”moarplz”. It’s hard to read for others and … Read more

Using “Read More” link with custom excerpt

This should remove the <p> tags, but leave the styling by replacing the paragraph tag with a <span> class: function all_excerpts_get_more_link($post_excerpt) { return ” . $post_excerpt . ” . ‘<span class=”readmore”><a href=”‘. get_permalink($post->ID) . ‘”>’ . ‘Continue Reading &raquo’ . ‘</span>’; } add_filter(‘wp_trim_excerpt’, ‘all_excerpts_get_more_link’);

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

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