Skip to content

Instantly share code, notes, and snippets.

@marcboivin
Created August 1, 2011 15:58
Show Gist options
  • Save marcboivin/1118413 to your computer and use it in GitHub Desktop.
Save marcboivin/1118413 to your computer and use it in GitHub Desktop.
Hacky way to make get_post_by_title work with qTranslate
<?
function qtrans_get_page_by_title($page_title, $output = OBJECT, $post_type = 'page' ){
global $wpdb;
// We append a < at the end of the like caus it's the ending charater
$page = $wpdb->get_var( "SELECT ID FROM $wpdb->posts WHERE post_title LIKE '%". $page_title ."<%' AND post_type= '".$post_type."'" );
if ( $page )
return get_page($page, $output);
return null;
}
//Consider using qtrans_get_page_by_title(__('Page name', 'textmodain');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment