- This topic has 19 replies, 2 voices, and was last updated 5 years, 6 months ago by Tom.
January 1, 2016 at 11:25 pm #162842Pete
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.January 2, 2016 at 12:58 am #162845TomLead DeveloperLead Developer
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?January 2, 2016 at 7:13 pm #163004Pete
I’ll refer them to this post 🙂January 2, 2016 at 10:58 pm #163033TomLead DeveloperLead DeveloperJanuary 4, 2016 at 5:02 am #163238Pete
This was the plugin author’s answer…January 4, 2016 at 6:56 am #163257Pete
I made a
incfolder in my child theme and copied the
template-tags.phpinto 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.January 4, 2016 at 10:31 am #163305TomLead DeveloperLead Developer
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.January 10, 2016 at 8:29 am #164768Pete
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.January 10, 2016 at 11:34 am #164852TomLead DeveloperLead Developer
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?January 10, 2016 at 11:37 am #164855Pete
Nope, here’s the WP support forum link… https://wordpress.org/support/topic/urlencode-error-messageJanuary 10, 2016 at 11:42 am #164859Pete
I tried it with this theme that also has pagination and it doesn’t throw the error…January 10, 2016 at 11:46 am #164862TomLead DeveloperLead Developer
Try adding this function to your site: https://gist.github.com/generatepress/11c0fb0eb9252ed26018
It removes the “trouble” code.January 10, 2016 at 11:58 am #164865Pete
I fixed it by commenting out line 38 in
// 'add_args' => array_map( 'urlencode', $query_args ),January 10, 2016 at 11:59 am #164866TomLead DeveloperLead DeveloperJanuary 10, 2016 at 12:00 pm #164867Pete
Thanks Tom, works a treat 🙂
- This reply was modified 5 years, 6 months ago by Pete.
- You must be logged in to reply to this topic.