Created
April 30, 2014 14:47
-
-
Save dcooney/f58244e86f8e054acec2 to your computer and use it in GitHub Desktop.
Get post id by slug and language
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function get_page_id($page_name){ | |
global $wpdb; | |
$sql = 'SELECT ID FROM '.$wpdb->posts.' LEFT JOIN '.$wpdb->wp_icl_translations.' WHERE post_name = "'.$page_name.'" AND language_code = "'.ICL_LANGUAGE_CODE.'"'; | |
$page_name = $wpdb->get_var($sql); | |
return $page_name; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment