• 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 12 replies - 16 through 27 (of 27 total)
  • Thread Starter wrightj999

    (@wrightj999)

    so just to follow up… I have tried inserting <?php the_content();?>, where I said I would in the previous post.. but to no avail. It must need to go somewhere particular.. I will wait for your advice ??

    Try replacing:

    <?php
    $content = get_the_content('read more');
    $content = apply_filters('the_content', $content);
    $content = preg_replace('|<img (.+?)>|i', '', $content);
    $content = preg_replace('|<div id="attachment_(.+?)" class="wp-caption(.+?)<\/div>|i', '', $content);
    echo $content;      ?>

    with:

    <?php the_content();?>

    Thread Starter wrightj999

    (@wrightj999)

    okay, so swapped out that code. To test if it worked, I went ahead and inserted an image at the end of the post. Alas, it is still appearing in the post excerpt. hmm…

    There are multiple Loops in that file. Try replacing:

    <p><?php $texter = get_the_excerpt();
    if(strlen($texter ) > 300) {
    	$texter = substr($texter , 0, 300);
    }
    echo ''.$texter.'[...]';
    ?></p>

    instead.

    Thread Starter wrightj999

    (@wrightj999)

    okay, I will reset the changes I made previously, try this option and be back with results.

    Thread Starter wrightj999

    (@wrightj999)

    okay, same result, no cigar. Do you think we need to get rid of both of those codes? I put back the code I had previously swapped out, for the purpose of this test.

    Thread Starter wrightj999

    (@wrightj999)

    One thing that I noticed that changed with that most recent code swap, was the “more” text display on page excerpts. It now says “read more” instead of “more” on the main highlighted excerpt. On the secondary excerpts instead of “…” it says “(more…)”. So that’s kinda cool i guess.

    okay, same result, no cigar.

    Well you have yet a third Loop with the same code block that you could try replacing further down the file.

    Thread Starter wrightj999

    (@wrightj999)

    yeah, so did that and same deal. Do you thing all of those codes need to be replaced simultaneously? Maybe getting rid of one isn’t enough to override the others… of course this is me speaking from a purely speculative view based off what we’ve done here.

    Do I lose any real functionality by getting rid of the code I have replaced in these different sections?

    Thread Starter wrightj999

    (@wrightj999)

    whoever originally designed this theme seems to have overcomplicated things, lol.. that’s just my opinion that doesn’t mean a whole lot though ??

    so the problem has been solved?

    Thread Starter wrightj999

    (@wrightj999)

    No, it has not been solved. While it’s not the biggest deal, and I can live with things as they are, for my own knowledge I’d still really like to know how to get what is discussed above to work. If you could shed some light on the subject, it would be much appreciated. Love the theme, you designed.. just ignore the above comment as I was maybe a tad frustrated, you did a wonderful job on the theme, lol ??

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