$postids = get_option('codeable_posts_field');
This will give you a string of comma separated post ids (according to your code, and if the user follows the instructions).
array( $postids )
will turn it into an array with that string as the only element. That won’t work with is_single()
, obviously, because is_single
doesn’t do any further splitting.
Here’s how to turn that string into a proper array using preg_split
. Replace
$postids = get_option('codeable_posts_field');
with
$postids = preg_split("/\s*,\s*/", get_option('codeable_posts_field'));
preg_split uses a regular expression to split a string into an array. I’ve added \s*
before and after the comma so that it will work for 123,456
and also for 123, 456
or 123 , 456
.
With $postids
being an array, your check should work just fine. If it doesn’t, try
var_export($postids);
to see what $postids really contains.
Related Posts:
- Custom plugin settings: clicking “save changes” does not display success message
- Redirect to another page using contact form 7? [closed]
- Best collection of code for your 'functions.php' file [closed]
- is_plugin_active function doesn’t exist
- How to Add a Third Level Sub Menu to the WordPress Admin Menu
- Is it a good idea to edit an already existing plugin to add more functionality?
- Checking if an attribute exists in a shortcode
- How to remove duplicate sub-menu name for top level menu items in a plugin?
- Where should I use get_option in a plugin
- Show Similar Post Titles ( Similar to Stack Exchange )
- How do I unlock a post programmatically?
- How to find out if option exists but is empty?
- How do I only load a plugin js on it’s settings pages?
- How can I limit functionality in one version of a plugin?
- Which functions in theme or plugin load first
- How to show custom message once on plugin activation?
- Add CSS animation as Preloader to WordPress
- How to list the Hooks and order of execution in current loading page? [duplicate]
- How to fetch serialized data from wordpress options
- How to load a new template page according to a particular URL?
- WordPress network: set themes and plugins for new blog
- Updating post meta for custom post types
- Get all options saved by another plugin
- REST-API: extend media-endpoint
- add action wp_head not working
- Is there a way to alter the order in which the plugins appear in the page?
- Default Plugin Settings Not Writing to Database
- Update Option Error: Notice: Undefined index
- Serialize data for wp options
- Get IDs of Images from Gallery Block in InnerBlocks of a Custom Gutenberg Block
- WordPress plugin – Error “Plugin generate 2890 characters of unexpected output when activated”
- My plugin wants to update another plugin
- Remove Duplicator plugin from admin menu if not an administrator
- Get plugin option in another PHP file
- Input with spaces in Shortcode attributes overwritten by defaults
- Add a custom form on the post-new.php admin page
- Edit Yoast SEO breadcrumbs output [closed]
- How would I go about creating a user ranked post popularity page?
- Display update notification messages like ‘What’s New’
- Add Plugin options as subpage to Theme options page
- custom payment gateway in woocommerce failed to connect to remote api server
- How to set add question capability for author role in wp pro quiz plugin
- php page not found for plugin options menu
- Customization API for plugin development
- Fromcraft Plugin On click submit button [closed]
- do_action() hook into load-(page)
- How to redirect users to their profile after they successfully edit their profile
- Admin AJAX doesn’t work in plugin admin page – Even though code is copied verbatim from WordPress Codex
- WordPress error: Options page Setting_ not found in the allowed options list
- How to use the CSS of the WordPress core in the development of my administration page?
- get_option / wp_localize_script Not Working in OOP Plug In
- Loop in elementor custom widget not working
- Calling a save function from a “submit” button
- Custom Module, Extending WP with a Plugin?
- Gathering all Custom Post Type posts in to array/object the proper way
- How to get values from network settings panel?
- Adding a jQuery modal dialog to the admin area
- unregister a sidebar widget
- Custom Post Type, Custom Columns List
- What is the most efficient way of adding additional functionaliy for admin only
- How to make sure settings are not lost when plugin is updated?
- wp_options not returning value for logged out users?
- How to save Setting pages data to the database?
- Check if theme supports sidebar
- How to create admin setting for this small plugin
- WC Fix Attributes – ‘Add New’ Not Searchable/Delayed
- Problem with MEMCACHE and Redis with wp_options
- Hide all Admin Notices and move on a separate page
- Changing the CSS with a plugin
- working code, not working – Plugin Dev
- Cannot view Custom Post Type no matter what I try
- Create survey that redirects to sidebar menu customized to answers
- Custom wp_list_tables redirect on specfic page
- Paid Membership Pro displaying a user name in PHP
- Load my Inline js footer area
- How to save the option’s new values plus old value without overwrite old one
- Woocommerce list variations that are added already to cart in Single Product
- WP options plugin setting not saving the selected checkboxes
- How do I add a textarea (multirow) option to my WordPress plugin?
- How to use custom footer template in a site-plugin?
- Creating Nested custom fields
- Get content and send to 3rd party
- Why is the WordPress update_option not working in this code?
- Confusing problem with displaying message recipient metadata
- Custom pages with plugin
- How to create a new database table whenever user changes options
- Validating values using Settings API?
- Multiselect value in wp_query
- admin panel save option with ajax
- Get page type to display content
- My first plugin doesn’t save the data in options
- WordPress Code Access to Restricted Content without Registration
- How to add image for custom taxonomy
- What can I do to customize a widget provided with this plugin? from where have I to start?
- Why haven’t I see plugins using get_file_data to handle retrieving plugin version?
- How can I properly sanitize the update_option in WordPress?
- Create Custom Coupon Type
- WordPress isn’t sending welcome email with the password reset
- How to make a Template page to show the information of different things Shop and Product page?
- move setting data from wordpress api to codestar freamwork