I am stuck on fixing a serious issue that took too much time than it should. I know it might be a small thing, but i spent too much time only to create a simple select query. Here is the code i am using to look at and tell me what is going wrong.

global $wpdb;
    $querystr = "
    SELECT $wpdb->posts.ID 
    FROM $wpdb->posts
    WHERE $wpdb->posts.post_type = 'product'
    AND $wpdb->posts.post_title = $tour_name
";

$productids = $wpdb->get_results($querystr, OBJECT);

foreach ($productids as $productid) {
echo $productid;
}

Read more here: $wpdb select prepare statement


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: