Support » Fixing WordPress » Controlling Image display in post excerpts

  • Hello,

    I’m wondering if there is some sort of tag that can be used (or some other methodology) to make it so that images in a post do not appear in the post excerpt. I just want certain posts to have images within the post, but to not display an image in the post excerpt.

    Thanks!!

Viewing 15 replies - 1 through 15 (of 27 total)
  • esmi

    (@esmi)

    Forum Moderator

    If your theme uses the_excerpt() all images will be removed from the post teaser.

    is there any chance I can apply that code to a single post? I want thumbnail images on some posts, and not on others. Where could I add this to get that effect? in the html of the actual posting?

    so putting that in the posting html does nothing, so that answers that. hmm, so it seems there is no way to customize this, it’s all or nothing? image thumbs on all post excerpts (with posts containing images) or none at all?

    esmi

    (@esmi)

    Forum Moderator

    I want thumbnail images on some posts, and not on others.

    So don’t add images to some posts…

    i guess i want more control over things than are possible, according to your feedback. I will give you an example of what I was trying to do, so you can at least understand where I am coming from. For my most recent post, there were no images needed in it. However, I wanted to punctuate the end of the post with the company logo.. it looked nice. However, I didn’t want it to appear in a thumbnail in the blog excerpt because right beneath the header of the blog, would be kinda redundant logo wise (as the logo is prominently featured in the header.) So I guess I should just give up on this desire? Not do-able?

    esmi

    (@esmi)

    Forum Moderator

    In that particular instance, using <?php the_excerpt();?> should work as it will strip out the image along with any other text formatting tags. The problem arises when you want some post teasers to include images and others to be just plain text. If you do want mix’n’match, then the only real option is to use <?php the_content();?> in conjunction with the <!--more--> tag. Then you can use:

    No images in teaser = insert images after the <!--more-->

    Want images in teaser = insert images before the <!--more-->

    Does that make sense?

    hmmm, so your suggesting to use <?php the_content();?>. Would I put this code into the actual post, similarly to how we use the <!–more–> tag? And if so, does it matter where I place it within the post?

    So if I get what your saying. Using <?php the_content();?> gives me the option to put images before or after <!–more–>, in order to get my desired result, as you’ve detailed above. That sounds pretty good, I’m just going to have to get straight, where exactly to place <?php the_content();?>.

    esmi

    (@esmi)

    Forum Moderator

    Would I put this code into the actual post

    What does the relevant theme template currently use?

    Would I put this code into the actual post,

    No – it’s strictly a template tag.

    right, okay.. so this is a part where maybe you can school me. So I’d be going to Appearance>Editor in the WP Dash and inserting this tag into one of the available php templates that make up the theme.

    These are what is available for options. Which template would I typically put a tag like this?:

    404 Template
    (404.php)
    Archives
    (archive.php)
    Archives Page Template
    (archives.php)
    Comments
    (comments.php)
    Footer
    (footer.php)
    Header
    (header.php)
    Image Attachment Template
    (image.php)
    Links Page Template
    (links.php)
    Main Index Template
    (index.php)
    Page Comment Page Template
    (page-comment.php)
    Page Template
    (page.php)
    Search Form
    (searchform.php)
    Search Results
    (search.php)
    Sidebar
    (sidebar.php)
    Single Post
    (single.php)
    Theme Functions
    (functions.php)
    theme-options.php
    (theme-options.php)

    Styles

    Stylesheet
    (style.css)

    Thanks!!

    oh yeah… and does it matter where in the template? Can I just add it within the php code that already exists, maybe at the end of it?

    esmi

    (@esmi)

    Forum Moderator

    Which template would I typically put a tag like this?

    Which page do you want this to appear in? You can find a generic list of what template is used in which page on the Codex’s Theme_Development page.

    awesome, I will refer to that resource. Thanks man, you’ve been quite a help, I know my needs have been somewhat basic.. but I guess that’s what makes the WP Forums great! When I get this implemented successfully, I will let you know 🙂

    okay, so upon doing that research I’ve determined that I have to add <?php the_content();?> within the “the loop” on the main index template: index.php. I’m wondering where to add it within the loop.

    So I was guessing to add it right before this code at the end of the loop:
    [Code moderated as per the Forum Rules. Please use the pastebin]

    Do I need to pass any parameters, or will just adding this tag add that extra functionality to the “more” tag that I am looking for concerning these image thumbs.

    After I get this figured out I will probably be adding at least one parameter to this tag in order to change the post excerpt display text of “more” to “read more”.

    esmi

    (@esmi)

    Forum Moderator

    Drop a copy of the theme’s index.php into the WordPress pastebin and post the pastebin url here, so we can have a look at it.

    You can just use <?php the_content();?> but it is also possible to customise the Read More link to suit your needs.

    Okay, here is a link to the paste:
    http://pastebin.com/rxSvnwcV

Viewing 15 replies - 1 through 15 (of 27 total)
  • The topic ‘Controlling Image display in post excerpts’ is closed to new replies.