Welcome to PressWork!

Want to ask a question or join the discussion? Great! Join now.

In this Discussion

where to insert qtranslate code?
  • i'm not very used to php and wordpress yet....i'm trying to install qtranslate language switcher with flags. every tutorial i've found says to simply insert the code where you want the switcher to appear.....i want it to appear in my first sidebar above my menu but i'm not sure in which file and where to insert the code!

    here's the code
    echo qtrans _ generate Language Select Code ( 'image' ) ;
  • cestbibicestbibi
    This answer was Accepted.
    To achieve this you need to use custom actions and hooks.

    Yo need to create a function and hook your code where you want it to appear.
    Don't worry it's easier to do than it sounds.

    If you go to the Toolbox editor in the front page , You can switch ON "Hooks" in the PressWork Settings.
    Now you can see where are the hooks and how they are called. From what you said in your post you'll probably need to use the pw_sidebar_top hook.

    So in your custom actions file http://presswork.me/2011/custom-css-and-custom-actions/ you can use the following code:
    <?php
    function add_qtranslateswitch() {
    if(function_exists('qtrans_generateLanguageSelectCode')) {
    echo qtrans_generateLanguageSelectCode('image');
    }
    }
    add_action('pw_sidebar_top', 'add_qtranslateswitch');
    ?>


    You'll probably want to style your flags with some css so they look good, there's plenty of examples in the Qtranslate forums.

    image PressWork Support Moderator
  • i guess i'm really confused...i added the code in the actions.php file but then i couldn't see my website anymore. here's a link to the code i used on pastebin since it was too big to post here.

    http://pastebin.com/kED5jPAa
  • You didn't follow the link I gave you, you have to create a custom actions file as explained here : http://presswork.me/2011/custom-css-and-custom-actions/
    and paste the code there. Don't put it in the actions.php
    image PressWork Support Moderator
  • yeah i just realized my mistake of not putting it in the custom actions file...i just redid it and it works now thanks :D
  • Great !
    image PressWork Support Moderator
  • but i'm still struggling with getting it to translate everything...now it doesn't translate the content or menus....i really hate this code stuff haha!
  • Qtranslate doesn't do the job alone, you have to input the translated content manually. If you want to automated translation you have to look for Google Translate plugin
    image PressWork Support Moderator
  • i know i already put some code in i'm just having trouble finding the code for content and the menu....but i know this is a presswork support not qtransltate lol :)