Divi WordPress Theme
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Removing first image on all posts with caption?

Discussion in 'Misc WordPress Requests' started by fouldsy99, Feb 21, 2018.

  1. fouldsy99

    Guest

    Removing first image on all posts with caption?, by fouldsy99

    I’ve come across this problem and I was hoping someone here might be able to help?

    What I am trying to achieve is to remove first image off all posts, including caption.

    I was using this code, but with no joy?

    function no_caption($deprecated, $attr, $content) { return $content; };
    add_filter('img_caption_shortcode', 'no_caption', 10, 3);

    function remove_first_image ($content) {
    if (!is_page() && !is_feed() && !is_feed() && !is_home()) {
    $content = preg_replace("/<img[^>]+\>/i", "", $content, 1);
    } return $content;
    }
    add_filter('the_content', 'remove_first_image');

    Image removal works, but not with the caption

    Removing first image on all posts with caption?
     
    #1

Share This Page

Monarch Social Sharing Plugin