wordpress

get post by title

function get_post_by_title($page_title) {
   global $wpdb;
   $post = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title = %s ", $page_title ));
   if ( $post )
      {
      $post= get_post($post, $output);
      //print_r($post);
      $language=get_bloginfo('language');
      if($post->post_type=="research"){
      $research_language= get_post_meta($post->ID, 'language', true);
     //  print $research_language. "   ".$language;print "<hr>";
     if($research_language!=$language)
      return false;
     else
       return true;
  }
}

  //  return null;
}
Advertisements