• Resolved bufny

    (@bufny)


    The theme I used allways displays the url RSS feed of the default language (eg. https://example.com/feed/). If I switch the language, the url of the RSS feed remains the same – but if I manually type another language in the URL, eg. https://example.com/fr/feed/ the feed apears correctly in french.

    How can I translate the url of the rss feed?

    The widget that shows the RSS feed button calls $theme->rss_url() and in the Themater.php I have:

    function rss_url()
        {
            $the_rss_url = $this->display('rss_url') ? $this->get_option('rss_url') : get_bloginfo('rss2_url');
            return $the_rss_url;
        }

    later edit:

    I guess I can hardcode something like this in the rss_url() function:

    if (pll_current_language() == "fr")
      return "https://example.com/fr/feed/"

    but I don’t like this solution.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Chouby

    (@chouby)

    The standard WordPress functions are filtered. So get_bloginfo('rss2_url') should work but I don’t know what is behind $this->get_option('rss_url')

    Does it work using the widget Meta? It uses get_bloginfo('rss2_url') and it works on my test site.

    Thread Starter bufny

    (@bufny)

    I have just called directly in my theme rss widget the get_bloginfo(‘rss2_url’) function and nothing… the default language feed is displayed for all languages.

    Also I have modified in the Themater.php:

    function rss_url()
        {
            return get_bloginfo('rss2_url');
        }

    and still dont work.
    ??

    However the standard meta widget works perfectly.

    le: I supposed that there is something wrong with my theme’s widget, its constuctor and widget function, and how it calls some functions from its base class, it seems that the filter its not applied…

    Plugin Author Chouby

    (@chouby)

    Are you setting the language from content? If yes could you try to set it from language code in Polylang settings? It’s possible that the function is called before the language is set.

    Thread Starter bufny

    (@bufny)

    Yes, the language is set from content. From language code, still don’t work. However, if I echo pll_current_language() in the widget code, just before the RSS button, the language is correctly displayed.

    Don’t bother anymore, thanks for your time. If I’ll find the bug, I will post the reason here.

    later edit: found it. The widget use some initialization array that was set before the language was set. At display time, I’ve made now a supplementary check that sets one of its component (the url) to get_bloginfo(‘rss2_url’).

    I’m sorry for wasting your time. Thanks for the support and for a great plugin.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘translating RSS feed URL’ is closed to new replies.