Any idea how I can use the WP function get_page_by_title() with qTranslate installed?

for example:

$page_contact = get_page_by_title( '_e("[:en]contact");' ,'page' );
$page_contact_ID = $page_contact->ID; echo '~~~~'.$page_contact_ID;

The only way I can get a match is by including the whole string with all the languages - and there is no way that's going to work once people start editing the pages...

  • Can you describe what is your overall goal ? do you want to create a menu by language ? to create a list of posts ?
    – krembo99
    Feb 22, 2012 at 1:04
  • Hi - I simply want to use the WP function as it was designed - so that I can get post data based on finding a match to a post name - perhaps a regex to remove the non-default languages and all the qtranslate comments might work?
    – Q Studio
    Feb 23, 2012 at 8:34
  • Again, I ask what is your FINAL goal, can you give a concrete example ? I am not asking about the WordPress function abilities . I just want to understand what is that you want to achieve in lame-mans-terms.
    – krembo99
    Feb 23, 2012 at 12:10
  • Hi - My aim is to make a menu using wp_list_pages - I want to exclude certain pages by page name - not page ID - as I will migrate the site from my localhost to at least one other server the ID will change - hence making it in theory easier to do this by page name - until I realised that qtransalte would interfere with this simple idea.
    – Q Studio
    Feb 24, 2012 at 20:39

1 Answer 1


Ok, now that you know your final goal I can try to answer :

first , A little background for other people who will read this and might wonder why this question exists (because it can help also in other cases )

the function get_page_by_title() does exactly what the name say . But qTarnslate , as well as other plugins , actually CHANGE the title in the DB .

The answer to such problems is using another less-known (but not less powerful) function called get_page_by_path();

why does this help ? Because the Path of the page will not be changed . Usually it will be used like this :


But a much more cool thing is that the "path" parameter can be the SLUG , which is NOT changed by qTranslate .

so for the direct answer , please try this :

$page = get_page_by_path('your-slug-of-page-to-exclude');

that being said, and as a side note - there is no reason for you to lose the ID of pages when migration, if you simply export your DB and import to the new server , like described in the CODEX or HERE.

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.