-
-
Save ptasker/3369855 to your computer and use it in GitHub Desktop.
WPML Get homepage IDs
This file contains hidden or 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
<?php | |
function get_wpml_home_ids(){ | |
//Globalizse the $wpdb variable (instantiation of the wpdb class) | |
global $wpdb; | |
//Get the front-page id from the options table | |
$home_id = get_option('page_on_front'); | |
//Run the query | |
$postids=$wpdb->get_col($wpdb->prepare(" | |
SELECT post_id.element_id | |
FROM `wp_icl_translations` AS trid | |
JOIN `wp_icl_translations` AS post_id | |
ON post_id.trid = trid.trid | |
WHERE trid.element_id = %d", $sc_home_id)); | |
//Return the array of post ids | |
return $postids; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment