$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.