Query by post title

You can use either search parameter of wp_query :

Code
$args = array("post_type" => "mytype", "s" => $title);
$query = get_posts( $args );

Or you can get posts based on title throught wpdb class:

global $wpdb;
$myposts = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->posts WHERE post_title LIKE '%s'", '%'. $wpdb->esc_like( $title ) .'%') );

Than you’ll get post object in this form:

foreach ( $myposts as $mypost ) 
{
    $post = get_post( $mypost );
    //run your output code here
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)