How to correctly limit the content and strip HTML?

First, I wouldn’t modify the string/word length of the content. Semantically, you’re dealing with an excerpt, so let’s focus on that. Second, to limit the number of words returned for the excerpt, simply filter excerpt_length: <?php function wpse52673_filter_excerpt_length( $length ) { // Return (integer) value for // word-length of excerpt return 150; } add_filter( ‘excerpt_length’, … Read more

First letter cutting off in excerpt

I’m going to give you a hard-coded solution to this problem, rather than using a plugin. If you’re heart is set on a plugin that is fine – but this short code is rather simple and hopefully helpful for your purposes. This code is basically just adding a CSS class to a shortcode. First, deactivate … Read more

adjust the_excerpt based on template page

You can add it straight to the template before the header in most cases… <?php /* Template Name: Products */ ?> <?php add_filter( ‘excerpt_length’, function( $length ) { return 10; }, 999); get_header(); ?> These should work as well if you’d rather put in functions.php: Method 2: In the loop $slug = get_page_template_slug($post->ID); if(‘page-products.php’ == … Read more

Read more on the post page itself

The solution might depend on why exactly you want it to work that way on the post page. But probably the best way would be to do this on the client side. Method with maximum height Let’s say your post template has its content like this: <div id=”content”><?php the_content(); ?></div> You need to add a … Read more

Twenty Fourteen: Change Read More text

In the twenty fourteen theme there is a plugable function named twentyfourteen_excerpt_more which generates the read more links. This function can be overridden in your child theme to use your custom read more link. All you need to do is add the following to your child theme’s functions.php file: /** * Overrides the parent function … Read more

Read More for Excerpt not working

You can modify the […] with simple function you place in functions.php function wpdocs_excerpt_more( $more ) { return ‘<a href=”‘.get_permalink( get_the_ID() ).'”>[…]</a>’; } add_filter( ‘excerpt_more’, ‘wpdocs_excerpt_more’ );

How to display only the excerpt in the blog/posts page with Gutenberg?

You should use a custom page for this. For reference, we can modify the default (twentynineteen) post content block. Depending on your theme, you may need to modify single.php, or a content block included from there. In the twentynineteen theme, we can see this on line 24: get_template_part( ‘template-parts/content/content’, ‘single’ ); Following that, we can … Read more

How to get excerpt correctly formatted

wp_trim_excerpt() calls wp_trim_words() which applies wp_strip_all_tags() to the excerpt. The <br> tag is removed and not replaced with anything. Not sure if this is feasible, but having a space after a colon is grammatically correct, and adding it to the original content would not affect the HTML, e.g.: <p>My new question is: <br>why words are … Read more

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