• I’m trying to get this to work with Pods templates, i.e. the backend shows translations, but the frontend only chooses the default language.

    This is only when going through a Pods template. When accessing fields directly they work. Any ideas?

    • This topic was modified 7 years, 4 months ago by bkkjim.
    • This topic was modified 7 years, 4 months ago by bkkjim.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter bkkjim

    (@bkkjim)

    One update: I had this function:

    add_filter('the_content', function($content) {
    	global $post;
    	return apply_filters('sublanguage_translate_post_field', $post->post_content, $post, 'post_content');
    });

    but the post title was not getting translated.

    So I took a guess and added this, and now the title translates.

    add_filter('the_title', function($title) {
    	global $post;
    	return apply_filters('sublanguage_translate_post_field', $post->post_title, $post, 'post_title');
    });

    I think I have everything translating now including when called in a Pods template. To clarify the original post, what I haven’t been able to do is have a Pods template itself with multiple languages. I’m guessing it’s solvable with a similar filter function, just don’t know how to write it.

    Thread Starter bkkjim

    (@bkkjim)

    Posted too quickly. That function messes up the theme.

    Plugin Author maximeschoeni

    (@maximeschoeni)

    Sorry I read you thread but still had no time to check this Pods framework. I’ll have a look as soon as I can.

    Thread Starter bkkjim

    (@bkkjim)

    Thank you so much, but I’d just as soon save your time because I’m about to post another question. I came up with a workaround. Pods template tags, called “magic tags”, can include a function to process a field. So {@ID,get_the_title} works for $post_title, and for $post_content this simple function works, called by the tag {ID@get_content}:

    function get_content($id) {
      $post=get_post($id);
    	return apply_filters( 'sublanguage_translate_post_field', $post->post_content, $post, 'post_content' );
    }
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Using with Pods’ is closed to new replies.