How to make WordPress orderby work with post_excerpt column?

I edited the wp_playlist_shortcode function at \wp-includes\media.php WP core file, by adding if ($atts[‘orderby’]==’excerpt’ || $atts[‘orderby’]==’post_excerpt’) { function cmp($a, $b) { return strcmp($a[“caption”], $b[“caption”])*(-1); } usort($tracks, “cmp”); } before $data[‘tracks’] = $tracks; line. Basically after all tracks are generated into the $tracks array and before this array is passed to the final array $data, I … Read more

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

How to show only the date, the title and a little “summary” of my WordPress post in my custom theme?

The get_template_part(‘content’, get_post_format()); line includes content from one of the other files in your theme based on the post type, the file name will be something like content-page.php (or content.php if the format is not found). If you print out what get_post_format() returns, you will be able to tell which content file to look into. … Read more

Merging two excerpt functions to work with conditions

Depending on where in the loop you call excerpt() wpautop might be creating the <p>…</p> wrapper. In that case, you could wrap $excerpt with <p>…</p> before returning it. Edit: Try this approach <?php echo excerpt(25).”\n”;?> (or possibly “\n\n”) to change the behavior. in function awesome_excerpt() you have $text = substr( $content, 0, strpos( $content, ‘</p>’ … Read more