Compare the_excerpt() to the_content()

Is there a way to compare the_excerpt() to the_content() to know if the_excerpt() is actually showing the entire post content? for instance, if a post were particularly short.

ultimately i’d like to have a “Read more” link at the end of excerpts. but i want it to say 1 thing for posts and another for posts of the video format (ie… ‘watch the video’ instead of ‘read the rest’). but at the same time i don’t want to manually tack this on after the excerpt, but i have plenty of posts that are short enough they don’t need a ‘read more’ link, since the_excerpt displays the full post.

but adding the permalink to the excerpt_more filter isn’t quite right since it won’t add a link to the video posts that have no other content.

so i’m stuck between the two. i hope that made sense. if it didn’t it’s late and i will try to re-explain in the morning.

2 s
2

What you’re trying to do with the video is exactly what Post Formats were created to handle.

Add this to functions:

add_theme_support( 'post-formats', array( 'video' ) );

And then this to handle your Read More link:

if( !has_post_format( 'video' ) ) {
    echo '<a href="' . get_permalink() . '">Read More&hellip;</a>';
} else {
    echo '<a href="' . get_permalink() . '">Watch the Video&hellip;</a>';
}

Leave a Comment