I have a website that displays a specific layout feature only on the homepage, and this is working fine. However, the client has suggested that they would like the website to be bilingual, and so I added a plugin to allow the transition between two languages.

Unfortunately, the plugin adds /?lang=cy to the URL and I fear it's causing my layout feature to break.

The conditional is relatively straight forward:

if (is_front_page()){ ?>
<?php }

When I choose to switch language, the layout feature disappears.

1 Answer 1


I'm not sure if lang is a reserved/used query variable in WordPress, but if it's not, then adding might help. Use a filter on query_vars like this:

function my_query_vars( $vars ) {
    $vars[] = 'lang';
    return $vars;
add_filter( 'query_vars', 'my_query_vars' );

Although WordPress will now know about the language query variable, I'm not sure what's causing your is_front_page() to stop returning true, perhaps it's not about your query variables but about the query itself, because is_front_page() depends on the $wp_query global object.

So how does your language plugin work? If you've set a page with an id of 10 as your front page, then is_front_page() for that page will return true, but if your language plugin is filtering the query and grabbing a page with an id of 50 (which is page 10 translated into Italian) then it's no longer the front page.

Give us a little bit more info about which plugin you're using to handle translations and if you wrote it yourself let us know how it works :)


  • I'm using qTranslate, and as far as I can tell, it just doubles the content of each page adding in <!-:en:--> and <!-:cy:--> to separate the languages, I don't think the pages double up as you suggested.
    – Dan Hanly
    Nov 28, 2011 at 15:07
  • 1
    @Daniel you can easily check that, before calling is_front_page try to print_r the $wp_query global and see what changes between the two requests (the one with the lang query variable and the one without it).
    – kovshenin
    Nov 28, 2011 at 15:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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