Skip to content

Instantly share code, notes, and snippets.

@ptasker
Forked from davidgtonge/gist:1227605
Created August 16, 2012 12:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ptasker/3369855 to your computer and use it in GitHub Desktop.
Save ptasker/3369855 to your computer and use it in GitHub Desktop.
WPML Get homepage IDs
<?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