$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]
- How to structure a plugin
- is_plugin_active function doesn’t exist
- Custom pages with plugin
- How to Add a Third Level Sub Menu to the WordPress Admin Menu
- WordPress Plugin Development In MVC Architecture, How?
- Is it a good idea to edit an already existing plugin to add more functionality?
- Checking if an attribute exists in a shortcode
- Is There a WordPress Hook to Filter the Edit Posts View?
- Add section (add_settings_section) to a custom page (add_submenu_page)
- 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?
- Create page when plugin is activated
- How to find out if option exists but is empty?
- How do I only load a plugin js on it’s settings pages?
- Creating button next to “add media” that allows you to choose a single post
- How can I limit functionality in one version of a plugin?
- Which functions in theme or plugin load first
- WordPress Plugin as ‘Library’ From Abstract Application?
- 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
- Add custom meta box on Post page
- 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
- Failed to invoke other hook from the init hook
- Can a plugin add to header/footer/body content?
- Created Widget Not Showing up on Admin Panel
- Get all options saved by another plugin
- REST-API: extend media-endpoint
- clean wp_options table unused rows
- How to set CORS header?
- add action wp_head not working
- Why is the Settings API is not saving my array of options
- Is there a way to alter the order in which the plugins appear in the page?
- Custom plugins/Manipulated plugins: Always a terrible idea to inherit these types of WP sites that discourage updates? [closed]
- Default Plugin Settings Not Writing to Database
- Update Option Error: Notice: Undefined index
- Serialize data for wp options
- How can I add an options page for my class based plugin?
- How to use get_theme_mod in gutenberg editor wordpress?
- 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
- JS Support Ticket – Auto create WP account
- 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
- All Users > User List > Update User Meta Field Inline
- 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’
- How to get specific setting by settings_fields()?
- Disable woocommerce cookies and delete cart data automatically
- How to fetch products with the price in a page on woocommerce using a form or live search with php
- Add Plugin options as subpage to Theme options page
- custom payment gateway in woocommerce failed to connect to remote api server
- Best way to maintain and update 3rd-party WP plugin when developer is unresponsive?
- 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]
- add tabs in rdp-plugin/includes/settings.php and get settings saved
- do_action() hook into load-(page)
- How to redirect users to their profile after they successfully edit their profile
- How to change the name of the “edit my profile” link in the WordPress admin backend
- Adding CSS to custom post type admin page causes error
- Admin AJAX doesn’t work in plugin admin page – Even though code is copied verbatim from WordPress Codex
- Custom post types – remove default post supports through empty array?
- WordPress error: Options page Setting_ not found in the allowed options list
- How can I run a custom shortcode function on a live site and only run if the viewer is a specific machine?
- Can I use register_settings and unregister_setting once the settings page has loaded?
- update_option_{$option} not showing old value
- remove all submenus from plugin
- Plugin function inside custom plugin
- Change the style of h1, h2, only in post entry
- Plugin getting Cannot modify header information errors
- Paid Membership Pro displaying a user name in PHP
- Installation failed, trying to install ANY plugin
- Load my Inline js footer area
- Plugin Options Page and Subpage
- 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
- Protect WordPress option value
- WordPress Boilerplate Plugin doesn’t see callback functions for add_settings_field and add_settings_section
- How do I add a textarea (multirow) option to my WordPress plugin?
- Manual Backup – How to save to Firefox or Chrome (instead of IE which brings up popup I can’t get rid of)
- 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