WordPress.org

Ready to get started?Download WordPress

Forums

Polylang
[resolved] Adding custom parameters to output of pll_the_languages() (3 posts)

  1. joschi81
    Member
    Posted 1 year ago #

    Hi Chouby,

    I'm looking for a solution to add custom parameters from the current URL to the language links in pll_the_languages.

    Example: I want the language links at

    http://www.mysite.com/list/?showyear=2012

    to link to

    http://www.mysite.com/language/list/?showyear=2012

    and not to

    http://www.mysite.com/language/list/

    Any hint how I can do this? Thank you!

    Regards
    joschi81

    http://wordpress.org/extend/plugins/polylang/

  2. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    You can use the filter pll_the_languages_link to filter the url returned by Polylang and set it to teh correct value for you.

  3. joschi81
    Member
    Posted 1 year ago #

    Hi Chouby!

    I tried it with the pll_the_language_link filter earlier today, but it didn't work. Now I tried it again and it works perfectly:

    add_filter('pll_the_language_link', 'language_link_query_args', 10, 2);
    function language_link_query_args($url) {
    	foreach($_GET as $key => $value){
    	  $url = add_query_arg($key,$value,$url);
    	}
    	return $url;
    }

    Thanks again for your great plugin!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic