WordPress.org

Ready to get started?Download WordPress

Forums

Polylang
[resolved] How to notify users that there are no translation for this post/page/category (5 posts)

  1. weeix
    Member
    Posted 1 year ago #

    When I try to change the language for untranslated post, it will link back to the front page.

    Are there any way to tell users that the post have no translation with a lightbox message or so?

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

  2. lloydo3000
    Member
    Posted 1 year ago #

    I think you need to modify the loop in your theme.

    Chouby provides a snippet here in the documentation, and there is a bit more information in this support topic.

    However I think it could be a good feature to request for a later version of Polylang. I suggested something similar to trap all of these error conditions:

    Since Polylang knows which language the user requested, maybe an error message in their language? You could provide a list of the languages available for that page, and even an online translation? Maybe:
    Sorry, the content you requested is not available in XXX language. You may choose from these currently available languages or try a machine-translated version.

    What do you think? Maybe some people would still prefer an option to direct visitors back to the homepage instead.

  3. weeix
    Member
    Posted 1 year ago #

    Yeah I think that would be great too.

    Not sure how to adapt the snippet for my case (I just wan't to deal with the link)

    I'm trying to figure out how to add some class to that link - something like class="pll-no-translation" - so I could use jQuery to deal with it. But with my current knowledge about WP & PHP, I'm not sure is that even possible lol

  4. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    You can send your visitor to a custom error page. You can add something like this in a custom plugin:

    add_filter('pll_the_language_link', 'no_translation_link', 10, 2);
    function no_translation_link($url, $slug) {
    	if ($url === null) {
    		if ($slug == 'en')
    			$url = get_permalink(x); // replace x by the id of the page you want to link to
    		elseif ($slug == 'fr')
    			$url = get_permalink(y); // replace y ...
    	}
    	return $url;
    }

    I will add a class "no-translation" in v1.0

  5. weeix
    Member
    Posted 1 year ago #

    Thanks, that's very nice of you.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic