Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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...

share|improve this question
    
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 '12 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 '12 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 '12 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 '12 at 20:39
add comment

1 Answer 1

up vote 3 down vote accepted

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 :

get_page_by_path('parent-page/sub-page');

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');
wp_list_pages('exclude='.$page->ID.'&title_li=');

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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