What it is doing, instead, is removing the first image from the_content() on all posts for the index page…
That’s because that’s what your callback is telling the filter to do. It returns true for all posts in your specified contexts (archive index, category index, blog posts index), not just for the first post in those indices.
…and removing the_content() altogether on all of the single pages.
That’s because, if your conditional returns false, you don’t return anything. You need to return $content;
outside of your conditional.
Related Posts:
- Using Switch Statement to Change Image According to Last Digit of Topic ID
- Function the_content
- Missing feature image link function
- Why isn’t is_page working when I put it in the functions.php file?
- Add image size if page template
- Set JPEG compression for specific custom image sizes
- remove links from images using functions.php
- Issue with wp_get_attachment_image() and SVG file type
- How to change the markup WordPress inserts for post images
- Difference between the_content() and get_post()?
- Programmatically Set First Image as Featured
- Removing default image size list in Media Box
- How to use get_template_directory_uri() to load an image that is in a sub-folder of my theme?
- WP 4.4. responsive loads normal image after loading the responsive image
- How to add classes to images based on their categories?
- How to create thumbnails for PDF uploads?
- Insert Ad Code in the Middle of a Post
- How to reduce original image quality on upload?
- Show/hide Widgets in Dashboard Based on Current Advanced Custom Fields Option
- How to display the_post_thumbnail if a post has one or otherwise display the first image in a post?
- Is it possible to maintain image aspect ratio when scaling images?
- Can shortcodes contain conditional statements? Even without them my shortcode renders blank page
- Auto delete WordPress images/thumbnails (all sizes) and featured after X days/hours, or similar?
- Set image size on media and text block with a function
- Generating Responsive Background Image Sizes in PHP
- Why are image thumbnails cropped proportionally (not per dimensions)?
- Create thumbnail on PDF upload with Gravity Forms
- If function exists, and array is met, echo function?
- Gallery images titles – get from post
- Remove images from get_the_excerpt
- Use Exact Image Size using add_image_size
- How to add a rel attribute to images that contains their categories?
- get_the_excerpt() not returning anything when post has no excerpt
- Why are image thumbnails cropped proportionally (not per dimensions)?
- Display height and width properties with the_post_thumbnail() or related function
- How to add a new image size and apply it to posts only?
- Changing where my author box is printed
- Insert Content Before div#main from the functions.php File
- Function to insert missing image size attributes into img tags
- Image Crop Not Working
- Use existing image sizes for WooCommerce
- Problem in using Customizer
- wp_get_attachment_image_src returns image on main domain, false on subdomain
- Retrieve First Image Function
- Custom Image Size in Insert Media
- If is_single in functions.php
- Featured Image keeps cropping
- Prevent creating multiple image resizes in twentytwelve template
- Using add_image_size in functions.php to get original uploaded file
- get_image_tag() html output : empty src attribute
- Need To Resize Images Exactly Without Losing Image Details
- Custom image sizes showing in Classic Editor only when upladed directly to post
- how can I change all wordpress media file url to custom cdn url?
- Different image using srcset function
- Is it possible to limit number of files a non-admin user can upload via the WordPress media library?
- Auto delete content in specific folder inside media library
- How to change images url in function.php?
- How to update an image attachment’s alt text from a custom field when saving a post?
- Class parameter in get_avatar args doesn’t get added to output
- large image size of 1440×1440 not pulling 2x of 2880×2880 image
- Can You Set A Minimum Image Dimension For Resizing Images?
- blank page with wp_get_attachment
- (Divi): How to make WordPress load images of specific size for Blurb modules on given page with a funciton?
- Strip all HTML tags from product content and resave
- Images with overlay
- Featured image on archive page based on post type
- Remove External Links from WordPress posts Using add_filter() in Theme functions.php
- Printing medium sized image
- $content is empty while using DOMDocument
- restrict uploaded image size and fixed image display size
- Why am I losing image quality on my site?
- Replace image attributes for lazyload plugin on image elements with specific class
- Disable links to images only if link is an image
- Restricted images only for logged user. (hidden url)
- Zip all (original) images from media gallery
- Shortcode to eliminate and replace with
- No compression occurs on my jpegs after adding jpeg_quality hook to my functions.php file
- How to display content If function exist/condition true?
- Different body image backgrounds on different pages, posts and categories
- Update add_image_size
- Open image size links in a page instead of direct image link
- Dynamically adding Captions to images
- restrict access to specific urls on a specific period of time
- Using conditionals, maybe from a DB, to register & enqueue files, for varying pages, in functions.php
- How accomplish modification the_content if home/start page?
- Full size image option removing problem
- Function to get thumbnail img source
- Image width issue in IE [closed]
- Creating mixture of shortcodes to use in the visual/text editor
- How I can show short content with short tag
- image_size with respect to aspect ratios
- How to resize image from import image url?
- How to crop image in WordPress with aspect ratio for any size of image
- How to add height and width dimensions automatically to archive descriptions
- How to overwrite image if it already exists – WordPress, Gravity form
- How Do I Prevent Featured Image Caption Displaying Above And Below Image
- How to force Cover block to use the full size image resolution
- warning: trying to access array offset on value of type bool ACF field image group
- Add custom text before all image captions in WordPress posts
- add_image_size() parameter four ($crop = true) is ignored: the_post_thumbnail() returns scaled image(s) instead of hard cropped