How to use the_excerpt in a filter hook?

use the filter get_the_excerpt. Look at line no. 250 here, they are using the_excerpt internally on the function get_the_excerpt(), and in this function on line no. 272, they’re applying the filter get_the_excerpt on the actual excerpt. Hence, add_filter(‘get_the_excerpt’, ‘exc’); function exc($param) { return “Whew !”.$param; } is the way to go if you want to … Read more

Custom excerpt length on home page

How filters work Filters are simply a point where you can take some value, that is set (for something) in core (for e.g. the the_excerpt() function), in open to modifications. So… $some_var = apply_filters( ‘change_this_var’, 50 ); …just says: »Some var« is set to 50, but when you add a filter callback to change_this_var, then … Read more

can the_excerpt function also get images?

Ensure that your Theme supports Post Thumbnails, and that the client sets a “Featured Image” for each post. Then, combine the_excerpt() with the_post_thumbnail(), e.g. like so: <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <div id=”post-<?php the_ID(); ?>” <?php post_class(); ?>> <div class=”featured-image”><?php the_post_thumbnail(); ?></div> <div class=”post-excerpt”><?php the_excerpt(); ?></div> </div> … Read more

wp_trim_words() does not trim the_content() in WordPress

The problem lies in this line: <?php echo wp_trim_words( the_content(), 55, $moreLink); ?> You call the_content function in there. This function prints all the content and doesn’t return anything. It means that you print the content, and then pass an empty string to the wp_trim_words. It should be: <?php echo wp_trim_words( get_the_content(), 55, $moreLink); ?> … Read more

How to Display Post Excerpts in Admin by Default?

The names of unchecked boxes in Screen Options for Edit Post screen are stored in user’s meta, per individual user, as an array. Insert the following code in your theme’s functions.php: function wpse_edit_post_show_excerpt( $user_login, $user ) { $unchecked = get_user_meta( $user->ID, ‘metaboxhidden_post’, true ); $key = array_search( ‘postexcerpt’, $unchecked ); if ( FALSE !== $key … Read more

Manual excerpts for pages not working on Search

You’re confusing “post type support” – which means enabling “feature” (and therefore MetaBoxes) for a post – with templating. Go into your theme, search for the search.php template in the folder. Add a Child Theme Add a file named search.php to your Child theme and copy/paste the content of your parent themes template file in … Read more

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