I would encourage you to consider using post formats. You can see my answer to a similar question about altering the “Read More” text, but it would apply similarly to you. For the video portion, you might want to create a custom field to hold the video URL, but otherwise, I imagine this would be quite simple to setup.
Rather than filtering the excerpt, this would also give you the option to replace the_excerpt()
with:
get_template_part( 'excerpt', get_post_format() );
Then you could use excerpt.php
for the default/fallback snippet, excerpt-video.php
for videos, and excerpt-image.php
for images. Alternately, you’d use something like this in your filter to test the post format:
if( get_post_format() == 'video' ) { // etc...
Related Posts:
- Using wp_trim_excerpt to get the_excerpt() outside the loop
- apply_filters() and the_excerpt are giving unexpected results
- How can I create a “Read More” link using the_excerpt() on a static front page?
- Compare the_excerpt() to the_content()
- How to get the unfiltered excerpt, without […] or auto-excerpting
- Display Links in Excerpts?
- Modify youtube video size on one page and show another size on different page
- Read more tag shows up on EVERY post
- Issue with enabling formatting in excerpts in WordPress
- limit the words in the post content and add read more link
- Custom excerpt length on home page
- Excerpt Word Count
- Limit the_excerpt in the first point (.) of the sentence
- How to show only manual / custom excerpts?
- Excerpts that don’t truncate words
- Spacing within the excerpt
- Modify Twenty Fourteen Home Page Content Limit & Add Read More Link
- “Read more” link doesn’t show up when the post length is under the excerpt length
- How do I disable excerpts on blogs and website
- the_excerpt Read More Filter
- How to get the excerpts of all children pages
- Custom excerpt showing first paragraph (with HTML formatting)
- Regenerate auto excerpts after updating many posts
- Remove whitespace before the_excerpt();
- Different ‘read more’ links
- How to display only the excerpt in the blog/posts page with Gutenberg?
- Bulk add tag (or any sort of label) to posts who have custom excerpt
- adjust the_excerpt based on template page
- How to correctly limit the content and strip HTML?
- Writing a custom excerpt function
- Getting first 20 words without excerpt
- Change excerpt length of first post
- Display oEmbed in the_excerpt
- Auto Populate Excerpt Field
- Remove Text within Header tags in the Excerpt
- Line in excerpt and max 5 lines
- Show the excerpt in a loop
- Custom Excerpts Per Page
- Include post title in readmore link?
- Excerpts automatically remove paragraph space
- How to apply excerpt length only on front end?
- get_the_excerpt() issues – returns the excerpt twice or not at all?
- Bug in the_excerpt() function
- Excerpt content
- Show excerpts of posts on P2 Home page
- How to change the length of excerpt() method?
- Removing h3s in excerpt output?
- get_the_excerpt without images
- How to get only manual excerpts?
- How to properly show the Excerpt only if it exists?
- The excerpt doesn’t add Read more
- How to get excerpt of the recent posts
- Problem with viewing single page correctly. (taken half way down the page on click through)
- Limit the size of the post excerpt
- excerpt box not visible
- I can’t modify the ‘Continue reading…’ link of the_excerpt
- Text with special class as excerpt (or exclude special class)
- get video from content
- Show Excerpts In Twenty Eleven Theme
- How do you edit the html of teaser excerpts
- Show image in excerpt post. Image not displaying
- the_excerpt() and tag
- the_excerpt is not limiting my post page to 55 words?
- I want to show post excerpt and cap it at 20 words [duplicate]
- Split the_content into two parts
- Use get_the_excerpt is returning nothing outside of loop
- How to edit a typo in excerpt?
- My post excerpt does not work
- Creating excerpt with simple “Read more” link
- How to remove excerpt white spaces
- making the […] clickable
- Modify excerpt link
- Reblog WordPress to another WordPress?
- What’s the internal concatenation function for creating Excerpts with WordPress?
- Append Second Link to Read More
- Twenty Eleven: Home Page, View full post of most recent post & Summary of the rest
- Get the automatic excerpt from a page created with gutenberg
- the_excerpt() is not trimming at
- Excerpts not showing
- “read more” tag for excerpt() won’t show full content
- Keep excerpt from stripping URLs and enable autoembed for youtube ONLY?
- Excerpt being limited too early
- Help needed using wp_trim_words
- NextGen Gallery not allowing me to display the_excerpt();?
- get_the_excerpt adding unwanted links to output html
- Excerpt functions is removing the forward slash on the url
- the_excerpt() doesn’t return the Excerpt field content
- Excerpt filter is adding ” in incorrect place
- 2 posts same excerpt?
- Edit the excerpt before it is shown
- Is there a html tag filter for the excerpt?
- Add rel=lightbox to custom string
- Excerpt is only getting shown for first post
- How to show excerpt field
- Post content not showing
- Export Posts in excel [closed]
- Limited excerpt with readmore
- Remove automatic excerpts only for single posts
- Setting post excerpt length in php wordpress code, Should will help to save DB size?
- Remove the excerpt and “… Read More” from the featured content on the home page with child theme