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
- Custom plugin: Trying to show saved data on frontend
- Is the first item returned by get_posts() always the latest post?
- How to store the_title() into a variable to reutrn the value, not just echo it
- Remove/unset options field from backend Settings->General?
- 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]
- How to update single value in multi dimensional Post Meta?
- Looping through WP_Post Object
- Using a javascript file to access a get posts array
- Passing array in add_option()
- Implement a multi-value input field where the number of entries is not limited
- 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?
- Listing and displaying WooCommerce Shipping Zones in the frontend? [closed]
- List of posts by day of the week
- Check if term object is in array
- How to get bool with `get_option()` when already registered setting with type `boolean`
- Create shortcodes within foreach loop (using array)
- Using a variable in is_page(array())
- Remove duplicates – array_unique()
- Adding Default Settings to Theme My Login plugin
- How to add values to media “whitelist_options” in wp-admin/options.php template?
- Recent posts with featured image or fallback image with permalink
- Storing Array from returned database query and using the array in a new query
- get_the_tags() not iterating through for/while loop, but will with foreach
- get a simple array of all of the term names that exist in all taxonomies
- Logged in user ID as post ID
- How to use $query->set with post__in?
- Reprinting tags with all attributes
- Open post-content in archive page in a Modal box with bootstrap
- get_posts() and WP_query limits ‘AND’ conditions to a maximum of 6 for meta value queries in WordPress
- Exclude posts based on meta value
- Checking array against author id in loop
- Query if audio attachment AND/OR custom field
- Redirect to another page using contact form 7? [closed]
- Alter required message using comment form api
- Advanced Custom Fields – display label and value only if value entered
- PHP Syntax Error on get_posts
- wp_force_remove_style’ not found
- How can I access string value in an array?
- How to array only one key from another array
- Filtering a function’ output for a new continued function
- WP_OPTIONS table, active_plugins entry [closed]
- Why is an array created in a function hooked to customize register populated when customizer is loaded but not when the front-end is loaded?
- How to say if meta_value is greater than 0 in an array?
- If Array Values Match Another Array’s Values, Then
- WordPress loop by meta key that is an array? and how loop multiple arrays
- Get all posts as an array ID => Name
- I’m unable to call img path using single quotes in an array?
- How to get image from url from the database?
- Comapare get_user_meta value
- How can get all users by current user meta?
- Get the id of all images in a post
- Output category list inside array
- Separate array output into a
- Update value of a associative array with update_post_meta
- How To Pass Array To get_the_category_by_ID() and Get An Array Back?
- Add custom fields from different posts
- MySQL Query Returns Array () In Shortcode
- How to get woocommerce orders with get_posts method in a shortcode
- Sending simple variable on single page to WP JSON
- Create an array with all the links of the years’ archive (of a custom post type)
- Redux option doensn’t seem when include from functions.php
- Set all WooCommerce Products to Simple, Virtual & Downloadable
- in_array not working on dev server but works on localhost
- How to display MySQL table data which is stored as an array?
- Foreach Loop Of Post Types With Nested If Else If Not Completing Process
- How can I render more than multiple posts on template-parts with post formats
- Show the subcategory name based on current product
- How to filter specific element of an array in wordpress/php?
- get_category_parents to array
- Notice : Array to string conversion on array_intersect user meta
- How to update option field in database on clicking the publish button in customizer
- Remove item from post_meta array via AJAX
- Fatal error when using array_diff() function inside of wp_update_nav_menu hook?
- PHP array to jQuery array ” Uncaught SyntaxError: Unexpected token < "
- Display posts using post ID’s in an array
- How can i iterate through this shortcode array?
- Display a single row from nested array of custom field data
- Create a hierarchical loop at predefined markup requirements
- Reformat data within a nested array
- How to find the function which is outputting Array
- Create Customization Controls from Array
- Sort posts by title, sort array by largest number [duplicate]
- Transient Loop Not working as expected
- !in_array doesnt recognize category
- Showing all post from all post type in admin backstage
- How to set if meta_value is lower < than other meta_value in a get_posts array?
- Populate checkboxes from array
- PHP Use Declared array Variable inside already Declared Array
- Echo get_option displays as text
- Why is my array_diff usage breaking things?
- How to group by column a and sum column b and c in a php array
- Adding date and time to the same request
- Link on post title only if post have content
- Get check box values inside array for use in posting form data
- Inserting more than one array into same row