Need to show post summary in sidebar

Easy way is use – excerpt() else you can also use wp_trim_words( get_the_content(), 40, ‘…’ ); In a excerpt(), You have to add content on excerpt in backend. While wp_trim_words will trim words from content. In sidebar case you have to add shortcode into functions.php file which uses in sidebar widget(if you are using widgets). … Read more

Post content not showing

Your query is structured a little weird. $my_query = new WP_Query( array( ‘posts_per_page’ => 5 ) ); if ( $my_query->have_posts() ) { while ( $my_query->have_posts() ) { $the_query->the_post(); // Your desired template code } // Close while() // Restore original Post Data wp_reset_postdata(); } // Close if() This should be all you need to set … Read more

Get the excerpt of post_content

I’m sure if you did some more research you would find this as it’s been asked many times before. If you just want all expert to return the value of 15 then you have to add something like this to your functions.php // Customize excerpt word count length function custom_excerpt_length() { return 15; } add_filter(‘excerpt_length’, … Read more

Implementing a blog excerpt in custom theme

It looks like your index.php file calls the content-page.php file. The code you are looking to change is probably in the content-page.php file. The key is this line: get_template_part( ‘content’, ‘page’ ); It is directing WordPress to load content-page.php

Function to shorten string without cutting off last word

There are various ways to achieve this as listed following. Using wordwrap() function : function shortened_description($cutlength) { $content = get_field(‘event_short_description’); $charcount = strlen($content); $content = wordwrap($content, 28); $content = explode(“\n”, $content); $shorter = $content[0]; if ($charcount >= $cutlength) { echo $shorter . ‘… <a href=”‘ . get_permalink() . ‘”>more ></a>’; } //$charcount >= $cutlength else … Read more

Excerpt Problems

Hopefully I’m understanding what you want correctly. I think you are going to need to wrap the content itself in a div called something like excerpt_content and make that an inline block that’s aligned to the top. Then you can use the has_post_thumbnail() as a conditional to assign it another class to limit the width … Read more

WordPress Post Format If Statement?

I believe you just need to add some “elses” into your php, like so: if ( has_post_format( ‘aside’ )) { // do some stuff } elseif ( has_post_format( ‘chat’ )) { // do some other stuff } elseif ( has_post_format( ‘gallery’ )) { // do some other stuff } else { // this isn’t a … Read more

Excerpt is only getting shown for first post

I suspect you’re misusing query_posts(), which is always and only ever intended to modify the Primary Loop. query_posts() is meant for altering the main loop. Once you use query_posts(), your post-related global variables and template tags will be altered. Conditional tags that are called after you call query_posts() will also be altered – this may … Read more