I’m getting some weird PHP warnings with the better-related-posts plugin: http://wordpress.org/extend/plugins/better-related/ but only on ONE particular post.
I have been using the plugin without any problems for some months now, but all of sudden these warnings showed up on my single template:
Warning: array_keys() [function.array-keys]: The first argument should be an array in /path-to/single.php on line 69 Warning: array_slice() expects parameter 1 to be array, null given in /path-to/single.php on line 69 Warning: array_search() [function.array-search]: Wrong datatype for second argument in /path-to/single.php on line 79
However, the related posts DO show up underneath these warnings with my custom query like this: http://pastebin.com/JacTv2mZ
(line 69 from the warnings is line 2 in pastebin)
So I tried to pindown the problem and it seems it’s only occuring when there is a <object> embedding in the post content like a soundcloud player in my case.
If I replace this original soundcloud embedcode with a shortcode (using this plugin):
[soundcloud params="player_type=tiny&color=006F9F" height="18"]http://soundcloud.com/trackname[/soundcloud]the warnings are gone.
My guess is that this embeddingcode is being included in the MySQL Fulltext Search and causing problems, but I think it should be excluded?
Does anyone have similar problems or have a solution or workaround for my problem? Any help is appreciated!
Even with the new HTML5 soundcloud code using iframes the problem occurs.
Did you find a solution for this?
I have the same problem…
No unfortunately not yet…
I have a workaround though to check if $scores returns an array, if not I use the normal the_related
I allready addressed the issue to the plugin author here:
Great. Thanks for the hint.
On my side I’ve found a sneakier way to “mask” the bug.
I actually turned off the php errors display in the wp-config.
SInce I was pushing the site into production I needed a quick solution.
While it will makes the error log grow, it still make it a viable solution.
+ it still shows the other related while clearing the array slice error.
error_reporting(0); @ini_set('display_errors', 0);
On my side the error was done using the integrated WP embed for youtube.
- The topic ‘[Plugin: Better Related Posts] Embedcode post causing: 'Warning: array_keys()'’ is closed to new replies.