Forums

the_excerpt with image (3 posts)

  1. AndrewBanchich
    Member
    Posted 5 months ago #

    I use the_content tag on my main blog page for the posts, and for searches, archives, etc. I use the_excerpt. However, I want an excerpt for my main page WITH the images but takes out youtube videos, etc. And I want the_excerpt on the other pages to stay the same, NOT showing images or anything. Is there some sort of code I can add to the the_excerpt so I can replace the_content on the main page with it and still get the images?

    I previously found a solution on another site where I could make ALL the_excerpt tags show images, but I don't want that to be true for the archives, search, etc.

  2. mattyza
    Member
    Posted 5 months ago #

    Hi AndrewBanchich,

    In your theme's functions.php file, you could take the code for the solution you found for the other website you mentioned in your post and wrap it in the following PHP Code:

    if (is_front_page()) {
    
    }

    That way, if the user is viewing the front page of your website, the code to rewrite the excerpt will be applied.

    I haven't tested this myself. Just a thought. Hope it helps. :)

  3. AndrewBanchich
    Member
    Posted 5 months ago #

    Okay, thank you! I'll give it a try.

Reply

You must log in to post.

About this Topic