Jetpack related posts and qTranslate-X fix

Problem:
I had some trouble getting Jetpack’s to play nice with qTranslate-X. The issue I had, was that Jetpacks Related Posts did not translate the post’s headlines and link title tags, and since this site is mulitlingual and most of the articles are both in Danish and English, this is a big problem.

jetpackvsqtranslate 01 Obviously with the many settings in the eco system, the fault could lie elsewhere, however a lot of switching off of plugins and settings, clearing caches and looking under the hood etc., led me to believe, that the fault is with . The fix is pretty simple, except it will be overridden next time I update the plugin, so I have notified the developers of .

In line 3, in the code snippet below, the original code is

return _strip_all_tags( $post_title );

which means that the posts title is returned to the system and stripped of all tags (syntax). The title is however not internationalised, in the sense that the system doesn’t account for any translations of the post title string.

The solution
The solution is to add __() around the $post_title so the line becomes

return wp_strip_all_tags( __($post_title) );

The place to make changes is: wp-content/plugins/jetpack/modules/related-posts/jetpack-related-posts. on line 697 (in version: 20150408 of the plugin)

protected function _get_title( $post_title, $post_content ) {
        if ( ! empty( $post_title ) ) {
            return wp_strip_all_tags(  __( $post_title )  );
        }

        $post_title = wp_trim_words( wp_strip_all_tags( strip_shortcodes( $post_content ) ), 5, '…' );
        if ( ! empty( $post_title ) ) {
            return $post_title;
        }

        return __( 'Untitled Post', 'jetpack' );
    }
Læs også  How to Pimp your Facebook Fanbox Facepile and Pagestream
%d bloggers like this:

Ved at bruge hjemmesiden accepterer du brugen af cookies mere information

Cookie indstillingerne på denne hjemmeside er aktiveret for at give dig den bedste oplevelse. Hvis du fortsætter med at bruge hjemmesiden uden at ændre dine cookie indstillinger eller du klikker Accepter herunder, betragtes dette som din accept

Luk