Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $myPosts = get_posts(array(
- 'suppress_filters' => false
- ));
- $lang='en';
- $title='The title you are searching!';
- function getWpIdByTitle($title, $lang){
- global $sitepress;
- // WPML Super power language switcher...
- $sitepress->switch_lang( $lang );
- $args = array(
- 'title' => $title,
- 'post_type' => 'your-post-type', // Default: post
- 'post_status' => 'publish',
- 'suppress_filters' => false,
- 'numberposts' => 1
- );
- $wp_query = new WP_Query( $args );
- return $wp_query->post->ID;
- }
Add Comment
Please, Sign In to add comment