Archived topic
urlencode error message...
19 replies · Started by Pete on January 1, 2016
Hi Tom. Happy New Year. I have the error message at the bottom of my search results page using this plugin... https://wordpress.org/plugins/ultimate-wp-query-search-filter/. I've been using the plugin for some time without any error but it threw this error on an update a few months a go (I don't know which one).
Warning: urlencode() expects parameter 1 to be string, array given in /home4/abc/public_html/xyz/wp-content/themes/generatepress/inc/template-tags.php on line 38
I'll PM you website/link if you like.
Thanks, Pete.
Hmm, so here's the block the plugin is having trouble with:
$links = paginate_links( array(
'add_args' => array_map( 'urlencode', $query_args ),
) );
It's a pretty standard piece of code when doing paginated links for your blog.
Does the author of that plugin have any idea why their code would cause a conflict with the above?
I'll refer them to this post :)
Cool - looking forward to figuring it out :)
This was the plugin author's answer...
https://wordpress.org/support/topic/urlencode-error-message?replies=2#post-7842553
I made a inc folder in my child theme and copied the template-tags.php into this folder with the plugin author's changes he proposed but it didn't make any difference. In any case I think the issue is his plugin rather than your theme, so I shouldn't really be editing the theme.
The piece of code I used there is quite popular - nothing fancy going on.
I'd be interested to know why the plugin isn't compatible with it, even if it means I have to change something.
OK, this issue only happens with the GP parent and my GP child theme. I tried it with 2012,2013,2014 and 2015 themes and they didn't have the error.
That's because those themes don't have paginated links for the blog.
Did the plugin author shed any light on why this may be happening?
Nope, here's the WP support forum link... https://wordpress.org/support/topic/urlencode-error-message
I tried it with this theme that also has pagination and it doesn't throw the error...
Try adding this function to your site: https://gist.github.com/generatepress/11c0fb0eb9252ed26018
It removes the "trouble" code.
I fixed it by commenting out line 38 in template-tags.php
// 'add_args' => array_map( 'urlencode', $query_args ),
That'll work until you update the theme.
Adding the PHP I gave will do the same thing but allow you to update as well :)
Thanks Tom, works a treat :)
