The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End WordPress – remove images from post lists but keep a word count

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
  • #210322


    I’m working on a WordPress custom theme blog homepage. I want to have an image for each post that is taken from a thumbnail image and want to have the first paragraph/cut off after say 200 characters and display ‘…’. I’m aware that you can do this with:

    <?php the_content('Read on...'); ?>

    However, I want to also strip out any images that appear in the post. Which I am currently using the following PHP to do:

    $content = strip_shortcodes($post->post_content);
    $content = str_replace(']]>', ']]>', $content);
    $content = strip_tags($content);
    $content = apply_filters('the_content', $content);
    echo $content;

    Is there a way I can combine the two to keep a word count AND remove any images in the_content();?

    Many thanks!

Viewing 1 post (of 1 total)
  • The forum ‘Back End’ is closed to new topics and replies.