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

Combining the_excerpt with the_content

The key is to use user-defined excerpts, rather than auto-generated excerpts. For example: <div <?php post_class(); ?>> <?php // If post has defined excerpt, output it here if ( has_excerpt() ) { ?> <div class=”first-paragraph-excerpt”> <?php the_excerpt(); ?> </div> <?php } // Now output the content the_content(); ?> </div> <!– .post –> You’ll need to … Read more

Replace full content with an excerpt

Decide about the_excerpt() or the_content() with a conditional: is_singular(). You can use a plugin and filter the_content depending on the current page’s type: archive or singular. But you can use it in your theme too. add_filter( ‘the_content’, ‘t5_replace_content_with_excerpt’, 100 ); /** * Return excerpt if we are not on a singular post view. * * … Read more

Show read more link next to last word

The only thing that makes sense to me is that $text immediately after this line: $text = force_balance_tags($out); Has something that wpautop translates as a paragraph break– something like a double newline. Untested, but I would think that trim would clear it up. $text = trim($text) . $excerpt_end;

Display oEmbed in the_excerpt

Without knowing more about your theme I can only hazard a few guesses. What are you inputting as an excerpt, what is the current output you are seeing for your excerpt, and what is the expected output? Are you seeing the URL show up in the excerpt, or is it being stripped? Oembed Are you … Read more

Easy way to show excerpts of specific posts on a page

You need a couple of things. A shortcode handler, and a custom query: function wpse_186346_excerpt_length() { return 50; } function wpse_186346_excerpt( $atts ) { $atts = wp_parse_args( $atts, array( ‘posts_per_page’ => 2, // Any other default arguments ) ); // We don’t need paging, always save a query $atts[‘no_found_rows’] = true; // Create query based … Read more

Change excerpt length of first post

Use the current_post property of the WP_Query object: function new_excerpt_length($length) { global $wp_query; // assuming you are using the main query if ( 0 === $wp_query->current_post) return 50; else return 20; } The function may need further tweaks to avoid interfering with other queries in unintended ways, but that is the basic idea.

Can I use both a custom excerpt and a trimmed excerpt?

We can try to filter the excerpt through the get_the_excerpt filter. By default, if we have a manual excerpt, the manual excerpt will be used and not the automatically created excerpt which is created by the wp_trim_excerpt() function. We can alter this behavior. What we will do is, when we are inside the main query … Read more

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