It happens because strpos returns 0 (zero index position) when gallery shortcode is at the start of the content which is treated as false
by the if condition.
Solution is to use Identical operator ===
in condition to check if the return value is a boolean false
.
Related Posts:
- How to manually fix the WordPress gallery code using PHP in functions.php?
- How to draw media details for Isotope gallery using Photoswipe
- Add a class to the anchor tag on HTML5 gallery
- Way to add captions to gallery images by code
- Custom gallery in wp3.5
- Auto create Nextgen Gallery on post creation [closed]
- Delete images from media library when user deletes an image from ACF Gallery
- Create shortcode for metabox gallery
- Display metabox galleries on specific page template in admin editor
- How to generate customized filtered output for the gallery
- Using catch_that_image() for galleries?
- Cleaning up WordPress to improve performance?
- List of all theme customizer control types?
- How can I modify the permalink via a filter?
- wp_set_object_terms and arrays
- How to get the original price of the product in woocommerce?
- How to use WordPress (PHP) functions in AngularJS partials files?
- The best way to customize “nav-menu-template.php” to add if the ‘link_before’ is “checkbox”
- How to add 2 posts under another post? Formatting should be intact
- Output a WooCommerce product custom field in WooCommerce using get_post_meta()
- How to return output of the new wp gallery block for automatically Link images To Media file
- enqueue multiple Google fonts with multiple weights and styles (italic)
- How to check If Oembed is empty or not
- What is the fastest way to load PHP functions that are only used in one theme template?
- Can’t load WP function into external function
- Image as Sales Badge
- WSoD being caused by this piece of code
- How to Arrange PHP Files to Allow for Multiple Types of Pages?
- Can I prevent the user from adding more than two levels deep of terms inside of a taxonomy metabox?
- Show css depending on activity type in BuddyPress activity-loop [closed]
- How to complete two other input fields, completed the first
- Retrieve $_POST data submitted from external URL in WordPress(NOT API)
- Css loads very slow [closed]
- Show when user is online/offline in real time on user_profile.php
- Compare the old get_theme_mod($name) to the new get_theme_mod($name) return value
- Scrape external webpage for first image and add it to new post
- How do I link a button I created in theme customizer to a function?
- Call to undefined function get_userdata() in plugin
- jQuery code not working when included in functions.php
- Fatal Errors on pluggable.php
- Log in / Log Out Custom Button
- how to test for all children (including multilevel grand-childern) of page
- Dilemma of Populating all the categories in a drop down list
- Add item to top of menu using a filter in functions.php
- Tell WP register script to load a script only when the entire page is loaded
- Can’t save php string to a custom field
- Limit Taxonomy Output in Conditional Statement
- wp_redirect only works on main site and not on other sites
- get_template_directory adding FTP root folders in urls
- Fatal error: Call to undefined function register_new_user()
- How can I hook into the wp_mail function used by BackWPup?
- List post by title length
- how to enqueque code in a php file from functions.php
- Only load certain artists on this page
- Deactivate a plugin on wp version
- the_post_thumbnail issues
- Some problems calling a function into sprintf() inside functions.php template file [closed]
- Convert all uploaded PNG files to PNG-8 format
- Uses for function: wp_update_user
- How to Redirect Buddypress Directories To Login Page For Non Logged in Users
- Woocommerce order status payment
- How to define a rule in functions.php that ONLY disables the default wp functionality that undesirably changes ‘&’ to ‘#038;’?
- Display logged in user name and lastname on page
- How to Add a cutsom slug to my custom author role
- How to output the taxonomies that are assigned to each custom post?
- Programmatically add a product to the cart and set price to zero when buying from certain category
- I want to show cart items number if any or nothing, simple CART text
- Exclude category from function – PHP
- How to escape echo for input tag?
- Hide a specific category title from displaying on site
- Display current user metadata on WordPress page
- Handling form actions in WordPress
- Need help with AJAX login to call php in functions.php to handle redirects based on user cap (role)
- Set user status to absent on WordPress
- Shortcode’s output to use as other shortcode’s parameter
- Populate Posts based on category selected using AJAX that means without page refresh
- Displaying POST content with HTML tags and all
- PHP script to redirect traffic based on website accessed
- How to remove title tag with this filter
- Why transition_post_type hook is called twice for the same post?
- Can’t get_users info by using json_encode
- What is wrong in this code?
- Retrieving specific images from Media Library
- Can’t put a hyperlink on Featured Post’s Image
- Page returning ID from array, how to return the correct values for post in acf wordpress
- WordPress HTML Helper
- Modify php code to pass a page id as a parameter in order to create a breadcrumb
- Show custom default avatar instead of gravatar
- List sibling pages widget, exclude current page
- Permission error on plugin save
- Removing all my hardcoded URLs with get_site_url()
- WordPress 2014 Theme – Featured Content with multiple tags?
- Display default WordPress login/registration form into a modal window
- Highlight main menu when on specific posts or pages
- Pull GET parameter from URL in functions.php
- Adding Gravity Form With if(is_page) Is Not Working
- Woocommerce – Shipping tax class based on cart items not using the highest tax available
- How to display the date under the post title?
- Custom Admin Menu Report for Specific User ID
- how to create twitter card without plugin in wordpress website?