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
- How to change the markup WordPress inserts for post images
- Difference between the_content() and get_post()?
- Programmatically Set First Image as Featured
- 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?
- Insert Ad Code in the Middle of a Post
- How to reduce original image quality on upload?
- 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
- 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
- If function exists, and array is met, echo function?
- 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?
- Display height and width properties with the_post_thumbnail() or related function
- Insert width & height attributes to all images displayed on each page
- Function to wrap the_content in a div
- Custom image size in Media Dropdown
- Conditions for Users and Visitors
- Removing the first image in content
- Function to auto-set a featured image that is already in use
- Actions according to image type and size
- Woocommerce Storefront WordPress Ignore Media Gallery Images and use External 3rd Party Host
- 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
- How can you limit srcset on a single type of page?
- how to add an image to the footer?
- str_replace function in theme
- wp_get_attachment_image function size argument not working if I also add a custom class
- Inserting a functions output after the content
- Add caption functionality to custom WordPress theme
- Understanding and altering the structure of posted images
- Removing permalink from post thumb in twentyeleven
- Publish/Update post is changing image links from file url to post url
- Featured Image Thumbnail Creation
- Twentyten Child Theme: header images display messed up in admin panel
- Disable auto-resizing of uploaded images, but only for certain filename
- Display images that are not in the content
- Can you put a condition on add_image_size() depending on the width of the uploaded image?
- show first 3 thumbnails of posts in different sizes [closed]
- Remove after images
- Getting custom image size URL in functions
- Can’t generate thumbnail images
- Control the srcset much more (not all sizes in it each time)
- How to hide image-url if no attachment?
- How do I pull excerpts from pages?
- What are the meta fields for an attachment?
- Undefined variable error in new function
- How to remove a specific word at the beginning of the content and add it to the end of the content
- How to properly set custom logo size?
- Add attribute only to first image of every post via functions.php
- How to Add Shortcode to html img code?
- The_content and Preg_replace in loaded Iframe [closed]
- 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
- Featured Image keeps cropping
- Prevent creating multiple image resizes in twentytwelve template
- get_image_tag() html output : empty src attribute
- Need To Resize Images Exactly Without Losing Image Details
- 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 update an image attachment’s alt text from a custom field when saving a post?
- 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
- Featured image on archive page based on post type
- Remove External Links from WordPress posts Using add_filter() in Theme functions.php
- $content is empty while using DOMDocument
- 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)
- Shortcode to eliminate and replace with
- No compression occurs on my jpegs after adding jpeg_quality hook to my functions.php file
- Different body image backgrounds on different pages, posts and categories
- 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
- Creating mixture of shortcodes to use in the visual/text editor
- How I can show short content with short tag
- Add custom text before all image captions in WordPress posts