You could use wp_parse_id_list()
to sanitize your comma seperated list of post IDs. It’s defined as:
function wp_parse_id_list( $list ) {
if ( !is_array($list) )
$list = preg_split('/[\s,]+/', $list);
return array_unique(array_map('absint', $list));
}
where we can see that it returns unique array values as well.
Note that absint()
is defined in core as abs( intval() )
and there’s a difference in the max output of intval()
for 32 and 64 bit systems according to the PHP docs.
Related Posts:
- save array of objects with update_option
- How to get WordPress Time Zone setting?
- Only get_posts of certain post formats
- Limit the number of inactive widgets
- Custom plugin: Trying to show saved data on frontend
- Is the first item returned by get_posts() always the latest post?
- Sorting list of sites from multisite network using wp_get_sites
- How to store the_title() into a variable to reutrn the value, not just echo it
- Metabox repeating fields – radio buttons not saving correctly
- Remove/unset options field from backend Settings->General?
- How can merge two arrays values in one array and save in database
- Site Title and Tagline in Theme Options Page
- Why can I not use setup_postdata($post) in the sidebar?
- How to retrieve a value from get_posts()? [closed]
- Editor role cannot save custom theme options
- WordPress customizer: load controls in a custom div
- How to update single value in multi dimensional Post Meta?
- Site Title and Tagline in Pagelines DMS Options Panel
- Enqueue Javascript Correctly for 3.5
- Getting movie and serial on actor page
- Error in WP_update_post
- Compare two meta key values against each other inside the get_posts array?
- how to display active, upcoming and past event with featured listing with pagination
- Looping through WP_Post Object
- Need to get specific data from array
- Display 4 chronological posts starting with a random post
- Using a javascript file to access a get posts array
- Create an array from an array
- WP_User_Query order by meta_key that is an array
- Passing array in add_option()
- Implement a multi-value input field where the number of entries is not limited
- Select dropdown not showing selected value php
- Generate an array of parent/child page IDs, based on parent page name
- Delete option value from array using update_option()
- Can an array be used as a meta_query value?
- Display a single row from nested array of custom field data
- How to replace hard-coded list of custom taxonomy terms based on custom field query [closed]
- Get a list of tags present in a paged front page
- How to use foreach and if statement within array of arrays?
- Create a hierarchical loop at predefined markup requirements
- offset and max_num_pages in pagination gallery
- Even with PHP plugin get_posts not working in widget area
- Add custom filter to register data in array
- Page returning ID from array, how to return the correct values for post in acf wordpress
- WP_Post is not from correct array
- Use get_option with $emailTo on contact page
- Reformat data within a nested array
- How to find the function which is outputting Array
- Create Customization Controls from Array
- Auto remove empty values in array
- Non-array argument in array_merge()-function [closed]
- Exclude Post ID from Array Specified in Custom Field
- Display a post based on its metabox selection
- Unserializeing multiple column values that are stored in one database results variable
- How to get values from wordpress listings and use them in javascript array?
- Repeatable field within repeatable group of fields
- Adapting a php array to WordPress
- WordPress Setting page can not be saved by html radio
- Sort posts by title, sort array by largest number [duplicate]
- wp_get_archive for category returning different URLs on different but similar sites
- Transient Loop Not working as expected
- show/hide attachments
- !in_array doesnt recognize category
- get_permalink returning first letter
- Showing all post from all post type in admin backstage
- Save Option on Database
- How to set if meta_value is lower < than other meta_value in a get_posts array?
- How to print array of specific item
- What is this mark for “? function()” [closed]
- How to combine array info [closed]
- Populate checkboxes from array
- Integrating CSS Into a WP Function Call [closed]
- Use php array outside his function
- PHP Use Declared array Variable inside already Declared Array
- Options.php loop won’t show!
- Retrieve Array from within Array [closed]
- Force array to be a string [closed]
- Echo get_option displays as text
- Why is my array_diff usage breaking things?
- get_body_params() is always empty in POST request
- Dynamic Email Handler with ‘header (“Location: …’
- Grabbing value of input field inside of array
- Custom WordPress Function – Adding items from Foreach Loop into an array and Updating Field based on array of IDs (ACF + WooCommerce)
- Find owner of coupon
- How to initialise WP_Query on the basis of a specific meta_value and continue iterating rest?
- How to group by column a and sum column b and c in a php array
- Replace block content with an array
- Adding date and time to the same request
- Link on post title only if post have content
- PHP how to submit array elements to database
- PHP – Converting elements to actual values
- WordPress Customizer add_control Dropdown of Pages with Multi Select?
- Send emails to individual subscribers when CPT post is deleted (trashed)
- How to pass php array to external js file in WordPress
- How to make posts_like_dislike reference current post when iterating?
- Category Attachment Pagination 404 Error on 2nd Page
- Get check box values inside array for use in posting form data
- Warning: Array to string conversion in /css/base.php on line 500 [closed]
- Updating from multiple array custom table
- Inserting more than one array into same row