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
- Set JPEG compression for specific custom image sizes
- Issue with wp_get_attachment_image() and SVG file type
- How to change the markup WordPress inserts for post images
- Programmatically Set First Image as Featured
- WP 4.4. responsive loads normal image after loading the responsive image
- How to add classes to images based on their categories?
- 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
- 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
- Create thumbnail on PDF upload with Gravity Forms
- Remove images from get_the_excerpt
- Use Exact Image Size using add_image_size
- get_the_excerpt() not returning anything when post has no excerpt
- Insert width & height attributes to all images displayed on each page
- Function to wrap the_content in a div
- Function to show only first instance of shortcode
- Custom image size in Media Dropdown
- Best way to programatically add “rel” attributes to page and post images
- Overwrite Parent Theme add_image_size in Child Theme
- Images uploaded using media uploader are appearing upside down
- How to add css class to image attached in all the posts?
- Add custom image size not working
- Searching for content post
- Count total number of images in post and echo results as number
- how to add an image to the footer?
- wp_get_attachment_image function size argument not working if I also add a custom class
- Adding HTML to the end of every post with the Block Editor
- Inserting a functions output after the content
- Automatically wrap multiple images in div
- Add caption functionality to custom WordPress theme
- Understanding and altering the structure of posted images
- Image rotation fails to regenerate custom sized thumbnail
- Removing permalink from post thumb in twentyeleven
- Publish/Update post is changing image links from file url to post url
- Featured Image Thumbnail Creation
- Display images that are not in the content
- show first 3 thumbnails of posts in different sizes [closed]
- Remove after images
- Getting custom image size URL in functions
- Set spesific size of featured images
- Can’t generate thumbnail images
- media resize/crop possibilities?
- Control the srcset much more (not all sizes in it each time)
- Way to store featured image width and height in two separate variables?
- Insert template-part inside the content
- srcset and custom field get_post_meta and wp_get_attachment_url
- Visual Composer creating own shortcodes with vc_map() to return simple Image
- How do I pull excerpts from pages?
- What are the meta fields for an attachment?
- does wp function the_content(); accept another tag inside
- How to remove a specific word at the beginning of the content and add it to the end of the content
- Woocommerce image sizes missing from Appearance › Customize but not declared by theme
- How to properly set custom logo size?
- Add attribute only to first image of every post via functions.php
- Need to convert image url to a Base_64 data url with wordpress function..
- The_content and Preg_replace in loaded Iframe [closed]
- first paragraph of the_content as meta description
- Changing where my author box is printed
- Function to insert missing image size attributes into img tags
- Image Crop Not Working
- Use existing image sizes for WooCommerce
- wp_get_attachment_image_src returns image on main domain, false on subdomain
- Retrieve First Image Function
- Featured Image keeps cropping
- Prevent creating multiple image resizes in twentytwelve template
- Using add_image_size in functions.php to get original uploaded file
- 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?
- (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
- Remove External Links from WordPress posts Using add_filter() in Theme functions.php
- Printing medium sized image
- restrict uploaded image size and fixed image display size
- 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
- Open image size links in a page instead of direct image link
- 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
- Function to get thumbnail img source
- Image width issue in IE [closed]
- 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 add height and width dimensions automatically to archive descriptions
- How to overwrite image if it already exists – WordPress, Gravity form