One (untested) suggestion is to replace:
unset( $classes[array_search($body_classes, $classes)] );
with
$classes = array_diff( $classes, wp_parse_slug_list( $body_classes ) );
assuming the classes survive sanitize_title
from wp_parse_slug_list()
. It should also be alright with empty arrays.
We also note that wp_parse_slug_list()
is using wp_parse_list()
to parse the comma separated string.
Related Posts:
- Can I query custom meta data through WP_Query
- When using add_post_meta and update_post_meta, is there any way to give the individual arrays keys?
- WP doesn’t show Array Custom Fields?
- How do I search an array stored in a custom-field using WP_Query?
- Is it possible to store arrays in a custom field?
- use get_posts to get custom field data, but in one array
- Saving an array in a single custom field
- Get specific custom field keys from a post and put into an array
- WP Query Returning All Posts
- Passing Custom Field Data as Array to be Saved (Resulting Custom Field Array is inconsistent)
- Run a check for multiple meta key values
- Create an Array of Specific Custom Post Meta
- Sort alphabetically by custom field
- change order of images attached to post
- query_posts with meta_value
- Displaying an ACF list of users
- Meta value Array
- Custom field to array?
- Show array of meta_value in Edit Post Coloum
- How to Convert Custom Fields from Text to Array?
- Custom field outside the loop and inside an array
- Get custom post fields from multiple metaboxes
- Working with multiple values and metaboxes
- Custom Field: how to save array of multiple key-values in WordPress
- How to save array option as text and not integer?
- Should I store arrays in custom fields or create custom tables?
- How do I use foreach to get content from a custom-field in multiple posts?
- Adding custom field to an array
- How do i output images from URL’s added to the same custom field key
- Extract array from custom field
- Build Array from Input Fields question
- Custom fields: Split data from single custom field’s sub-array to separate custom fields when saving post
- WP_Query – Order results by meta value
- Custom query with orderby meta_value of custom field
- Orderby meta_value only returns posts that have existing meta_key
- How to enable revisions for post meta data?
- Including custom fields in search?
- Sort posts by custom field numeric value using dropdown
- How to position a custom field before the editor
- How can I display all values of a custom field from posts with a certain value of another custom field or from certain post types?
- searching in custom meta field
- How to add upload field in a custom taxonomy?
- Display thumbnail from custom field
- Bulk move (or copy) from a custom field to the post content?
- Getting Custom Field data from a page hierarchy
- Custom contact form 7 select with custom values [closed]
- limit amount of photos uploaded per cpt post
- Problem with adding exta field in metabox in custom post type
- Add WYSIWYG to Image Description field
- Calling custom profile fields?
- Show ACF fields only on certain page in the backend
- Create Multiple File Upload Metabox in WordPress
- WP_User_Query pulling ACF to loop
- how to put a custom field value in variable
- Storing a DateTime Value in a Sortable Custom Field?
- How to show a post if was published less than two hours ago?
- Custom field as Slug
- How to save the date/time of last update of an extra user profile field?
- How to populate custom field dropdown box based on prior selection?
- Define a post’s title and slug from Custom Fields
- How can you include custom post meta in search without calling each key?
- Custom wysiwyg editor doesn’t execute shortcodes?
- How to hide a div based on contents of custom field
- Hook after meta created
- What is the largest value you can store in a custom field (as meta data for a post)?
- Where does this field get its value?
- Get all the posts where meta field with multiple choice has several values checked
- Warn user that data may be lost for custom pages
- List custom field values in alphabetical order without repetition
- Can’t query by meta_key
- Display MP3 as media using an URL from a custom field
- WordPress custom fields feature is missing in my installation
- Print Posts if Custom Field Value Date equal or greater than Today Date
- Update post meta custom field using block editor
- If I update WordPress my custom data will be deleted from the wp_users table?
- Get emails from users by custom field SQL
- Convert all dates stored in custom field
- Why am I getting a “Call to member function format() on a non-object” error?
- HM CMB: Role Select
- Custom Query Fields – Altering Meta Value
- Adding re-type email and check it if the email match
- show a specific metabox dependent on the page template
- excluding posts by an ACF field in pagination
- Search & column order by meta value in admin
- Exclude URL’s from sanitize_html_classes
- How to add a post’s view count into the WordPress API response
- How can I ‘check’ the “custom fields” box from the Screen Options?
- How to get all wp_posts in wordpress fetched from database
- automatically add custom fields to post title
- Custom Fields Permalink Plugin not observing hyphens
- will wp_insert_post write a new custom field to the database?
- How to repeate custom field group with bulk image field
- Extra text’n’image field in a page
- Get first URL from custom field, download and set as featured image on post publish
- How to add an option to admin to add image that could be used as header?
- How to query posts that have certain post meta keys, and sort by meta key and/or value
- Foreach giving one too many list items, how can I remove the last empty line?
- Add custom fields to specific menus
- Multiple triggers when publishing, saving or updating a post in WordPress
- If possible a field ID transfom in a Custom Field?