4

I'm trying to find a way to selectively disable qTranslate - I would like to be able to show certain static content on my site in 4 languages, but to then only have a single language (and a simplified editor) for posts and also custom post types.

I would also need to disable the output on selective pages in the front-end, so that I can show all the language content on the same page, at the same time.

Is there a way to have the plugin load on demand?

2
  • 1
    This is a user support, Plugin-specific question that would be better-directed to the qTranslate Plugin support forum. Commented Feb 10, 2012 at 20:08
  • thanks chip - I did also post a question there, just hoping to find a good solution and so asking in a few places where those answers might come from...
    – Q Studio
    Commented Feb 14, 2012 at 19:20

2 Answers 2

3

Following snippet will disable it for post_type post (modify array below to affect other post_types):

function qtrans_disable()
{
    global $typenow, $pagenow;

    if (in_array($typenow, array('post')) && // post_types where qTranslate should be disabled
        in_array($pagenow, array('post-new.php', 'post.php'))) 
    {
        remove_action('admin_head', 'qtrans_adminHeader');
        remove_filter('admin_footer', 'qtrans_modifyExcerpt');
        remove_filter('the_editor', 'qtrans_modifyRichEditor');
    }
}
add_action('current_screen', 'qtrans_disable');

Similarly you can disable it for specific post IDs. However take into account that this won't affect already existing multi-languaged content. Therefore use it before you enter any.

3
  • Be careful with this if enabling the "Hide posts not available on the current language" option in qTranslate: it will effectively hide any new posts from these post types where you disable the qTranslate editor in archives, search results and other listings. You'll need to filter out the posts_where clause to remove the LIKE "%<!--:en-->%" check that qTranslate adds to all queries for these post types.
    – guidod
    Commented Dec 5, 2013 at 18:27
  • Thanks for the function. I've updated the hooks to work with QTranslate Plus. It seems impossible to add formatted code here, so I posted on my website:
    – Hannes
    Commented May 28, 2015 at 16:21
  • etzelstorfer.com/en/…
    – Hannes
    Commented May 28, 2015 at 16:32
1

There is an answer in the qtranslate forum that seems to address this. It involves changing the core files of the plugin, though. Any luck with it?

5
  • thanks for the link - I did also post my question on the qtranslate forum, but stackexchange is far more active.. would be great to be able to avoid changes to core code, such as making an addition to functions.php - do you think that could be possible?
    – Q Studio
    Commented Feb 11, 2012 at 11:40
  • I did a quick search, and I don't seem to be able to find a hook where to do this in current versions of qtranslate... It would be a good addition, though, and I could see uses for it myself as well, so I would be very interested in hearing how you will get around it! :-)
    – englebip
    Commented Feb 11, 2012 at 22:13
  • the solution in the qtranslate forum seems to be to disable the back-end - I simply need to disable the plugin in the front-end now.. any other ideas?
    – Q Studio
    Commented Feb 15, 2012 at 20:35
  • What do you mean disable the plugin in the front-end? Not show the language-change switch when you're displaying the custom post type? You could do that by using a conditional tag perhaps?
    – englebip
    Commented Feb 17, 2012 at 13:31
  • I will have some static pages in 4 languages - thanks to qtranslate - then I want posts and other CPT's only in a single language - I'll use a front-end editor to allow users to add these - however, they do not always display correctly due to qtranslate taking over the display of the content on all post types.
    – Q Studio
    Commented Feb 18, 2012 at 18:07

Not the answer you're looking for? Browse other questions tagged or ask your own question.