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

    (@chouby)

    Has this author written any post in that language?

    Thread Starter e-colori – Tobias

    (@e-colori)

    OK, I see.
    I am not showing all the posts the author has written (loop) on that page.

    It shows author infos from the DB: users and user_meta: Name, description, nicename etc.

    Plugin Author Chouby

    (@chouby)

    Since v1.2, Polylang checks that there are posts on translated archives urls to avoid 404 errors.

    This custom plugin should disable the check for author pages (not tested):

    <?php
    /*
    Plugin name: forces Polylang linking to author translation
    */
    
    add_filter('pll_translation_url', 'pll_author_translation_url', 10, 2);
    
    function pll_author_translation_url($url, $lang) {
    	if (is_author()) {
    		global $polylang;
    		return $polylang->links->get_archive_url($this->model->get_language($lang));
    	}
    	return $url;
    }

    Thread Starter e-colori – Tobias

    (@e-colori)

    Thank you for your fast answer.
    It gives me this warning:

    Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'pll_author_translation_url' not found or invalid function name in C:\xampp\htdocs\confi\wp-includes\plugin.php on line 199

    And it does not do the trick ;-(

    Plugin Author Chouby

    (@chouby)

    I don’t get this warning, so there may be a copy paste issue. However making the test, I noticed an error even worse.

    <?php
    /*
    Plugin name: forces Polylang linking to author translation
    */
    
    add_filter('pll_translation_url', 'pll_author_translation_url', 10, 2);
    
    function pll_author_translation_url($url, $lang) {
    	if (is_author()) {
    		global $polylang;
    		return $polylang->links->get_archive_url($polylang->model->get_language($lang));
    	}
    	return $url;
    }

    It enables the link to an empty author page (a page not found in twenty twelve).

    Thread Starter e-colori – Tobias

    (@e-colori)

    Thank you for testing.
    Any suggestions how I could solve the problem, if my theme does use and support an author.php file for showing author infos from the DB: users and user_meta: Name, description, nicename etc. ?

    Plugin Author Chouby

    (@chouby)

    If the new plugin above dos not work, I have no other idea. Is your theme freely available?

    Ok, is working, url is changes,
    but when I switch lang, pll_current_language() display only one value (default lang?)

    How can fix it?

    Plugin Author Chouby

    (@chouby)

    I did not test but a possible explanation is that if there is no post (no content) then Polylang can’t set the language from content thus uses the last browsed language. Maybe you can try setting the language from the language code in url.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Theme page: author.php returns to home instead of other language’ is closed to new replies.