Forums

[resolved] the_content without thumbnails? (7 posts)

  1. WMS Group
    Member
    Posted 1 year ago #

    I am using a theme that grabs the post thumbnail from the custom fields meta. It also uses the the_content_limit which I am trying to get rid of. When I change the the_content_limit line back to the_content, I am getting double thumbnails since by default it grabs the image as well. Is there a way to tell the_content to not include the post thumbnail?

    Thanks.

  2. Mark / t31os
    Moderator
    Posted 1 year ago #

    I believe the_content only includes the images you've inserted into the editor when writing the given post or page, can't you simply remove that code from the post/page 's content since you're using some other code to display those images.

  3. WMS Group
    Member
    Posted 1 year ago #

    Thanks t31os, that makes sense, but it only uses the custom fields on the homepage. If I take the_content out then it will not retrieve the post's text.

  4. WMS Group
    Member
    Posted 1 year ago #

    I actually found the solution :)

    <?php
       ob_start();
       the_content('Read the full post',true);
       $postOutput = preg_replace('/<img[^>]+./','', ob_get_contents());
       ob_end_clean();
       echo $postOutput;
    ?>

    I read this in a post from 2 months ago here

    I had to tweak it a little for my needs but it seems to be working great.

  5. Mark / t31os
    Moderator
    Posted 1 year ago #

    Sorry i think you misunderstood what i was saying before, the images displayed by the function the_content are generated by code inserted into the editor when you have writen the given page or post.

    Simply deleting the code inside that post or page for the image should in effect stop the_content outputing the images, leaving your custom code to grab the image(s) associated with that post or page.

  6. WMS Group
    Member
    Posted 1 year ago #

    Thank yout310s_. My last post did the trick for me. I appreciate your quick response!

  7. Mark / t31os
    Moderator
    Posted 1 year ago #

    Whatever works.. ;)

    Just pointing out the solution you've used above is not really required, but if you're happy with what you have, then we're all good... :)

Topic Closed

This topic has been closed to new replies.

About this Topic