[Resolved] urlencode error message…

Home Forums Support [Resolved] urlencode error message…

Home Forums Support urlencode error message…

Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • #162842
    Pete

    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.

    #162845
    Tom
    Lead Developer
    Lead 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?

    #163004
    Pete

    I’ll refer them to this post πŸ™‚

    #163033
    Tom
    Lead Developer
    Lead Developer

    Cool – looking forward to figuring it out πŸ™‚

    #163238
    Pete
    #163257
    Pete

    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.

    #163305
    Tom
    Lead Developer
    Lead 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.

    #164768
    Pete

    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.

    #164852
    Tom
    Lead Developer
    Lead 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?

    #164855
    Pete

    Nope, here’s the WP support forum link… https://wordpress.org/support/topic/urlencode-error-message

    #164859
    Pete

    I tried it with this theme that also has pagination and it doesn’t throw the error…

    #164862
    Tom
    Lead Developer
    Lead Developer

    Try adding this function to your site: https://gist.github.com/generatepress/11c0fb0eb9252ed26018

    It removes the “trouble” code.

    #164865
    Pete

    I fixed it by commenting out line 38 in template-tags.php
    // 'add_args' => array_map( 'urlencode', $query_args ),

    #164866
    Tom
    Lead Developer
    Lead Developer

    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 πŸ™‚

    #164867
    Pete

    Thanks Tom, works a treat πŸ™‚

    • This reply was modified 8 years, 2 months ago by Pete.
Viewing 15 posts - 1 through 15 (of 20 total)
  • You must be logged in to reply to this topic.