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?
- 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?
- Editor role cannot save custom theme options
- Error in WP_update_post
- Compare two meta key values against each other inside the get_posts array?
- Looping through WP_Post Object
- Using a javascript file to access a get posts array
- 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
- ‘orderby’ => ‘rand’ alternative for better performance?
- Store and Work with huge array in WP [closed]
- Create shortcodes within foreach loop (using array)
- Using a variable in is_page(array())
- Remove duplicates – array_unique()
- 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
- Whitelisting items from custom options page
- 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
- Checking array against author id in loop
- Only showing the_date and the_excerpt for first entry in get_posts
- Error: options page not found
- How to store options in an array
- how to update and display an option without reloading the page
- Redirect to another page using contact form 7? [closed]
- Security for data obtained from the database
- Grouping posts by a custom meta value
- Pull GetOption() variable into jQuery dynamically created html
- Filtering a Database Query
- How i can get post data from database when i am getting post id from url in wordpress
- WP_OPTIONS table, active_plugins entry [closed]
- Error while setting role
- How to say if meta_value is greater than 0 in an array?
- Loop over Array and get the distinct ids
- Remove empty terms from array, sort alphabetically, update back to repeating field
- Only show first image in foreach loop
- How to show every second user different types of banners?
- How can I get all values from my array in a loop in php? [closed]
- Get all posts as an array ID => Name
- Filter by field with array value in ACF on WP REST API
- How to get image from url from the database?
- Separate array output into a
- Only load certain artists on this page
- add the value of a variable returned in a while loop [closed]
- Update value of a associative array with update_post_meta
- using images in next/previous_post_link [closed]
- Get value from db for custom contact form
- Page Options Saving But Not Updating In Backend
- Add class to every other posts using get_posts
- MySQL Query Returns Array () In Shortcode
- search.php to search only the post title
- How to get woocommerce orders with get_posts method in a shortcode
- get value from get_post_meta then reuse it in another get_post_meta
- Convert a column of a table containing an Array as response in HTML
- Create an array with all the links of the years’ archive (of a custom post type)
- Display just one post from a loop of 5 posts?
- Redux option doensn’t seem when include from functions.php
- Set all WooCommerce Products to Simple, Virtual & Downloadable
- Creating an array from form inputs before it is posted to the options database
- How to make a pagination with dropdown selection?
- How to insert multiple rows and columns in database using array
- Display one random image from Media Library
- ACF – Get ID of relationship field in flexible content
- Replace an array (with identical values) with another array in the_content
- get_category_parents to array
- How to display post_content from database in different on template page?
- Displaying POST content with HTML tags and all
- How can get all users by current user meta (array)?
- How can i iterate through this shortcode array?
- 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
- Page returning ID from array, how to return the correct values for post in acf wordpress
- Non-array argument in array_merge()-function [closed]
- 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
- get_permalink returning first letter
- Showing all post from all post type in admin backstage
- Integrating CSS Into a WP Function Call [closed]
- Use php array outside his function
- Options.php loop won’t show!
- Retrieve Array from within Array [closed]
- Grabbing value of input field inside of array
- How to group by column a and sum column b and c in a php array
- PHP how to submit array elements to database