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

how to use the_excerpt for two post queries?

function excerpt($limit) { $excerpt = explode(‘ ‘, get_the_excerpt(), $limit); if (count($excerpt)>=$limit) { array_pop($excerpt); $excerpt = implode(” “,$excerpt).’…’; } else { $excerpt = implode(” “,$excerpt); } $excerpt = preg_replace(‘`\[[^\]]*\]`’,”,$excerpt); return $excerpt; } write below code in your template. <?php echo excerpt(25); ?>

multiple excerpt length and styles

Are you aware of the uses of the More Tag? Customizing the Read More shows many uses of variable length teasers with variable link phrases to read more. For example, this markup entered in the Post editor will provide a link with Read the rest of this story in the anchor text. <!–more Read the … Read more

Add rel=lightbox to custom string

Without seeing the html output for the excerpt thumbnails it is difficult to say why your code is not working. However I would also look into str_replace (http://php.net/manual/en/function.str-replace.php) as a possible solution to your problem.

Is there a html tag filter for the excerpt?

You can pass in HTML formatting within custom excerpts and output it via the_excerpt() or get_the_excerpt() in your template files. Check your template files for additional custom filters added to the_excerpt() or get_the_excerpt() if the HTML formatting is removed anyway.

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