David McClave
David McClave

Reputation: 167

Wordpress meta_value query not working

Losing my mind. Long time customizer of Wordpress. THIS query has me baffled.

I have a record in wp_post meta where the following exist:

the following query returns nothing:

if($events = $wpdb->get_results("SELECT post_id FROM wp_postmeta WHERE meta_value = 'frontpage';" )){
                    print_r($events);
}

What am I doing wrong?

Upvotes: 0

Views: 194

Answers (2)

David McClave
David McClave

Reputation: 167

OK, for my particular issue, Thanks to Omar Tariq, I have the answer - the page I was making is outside of my Wordpress system, and the theme I am using is a heavily-modified and customized theme with many custom post types. The solution is to SIMPLY use the MYSQL API in PHP, instead of using $wpdb. This was fast, simple and easy. I wish I could delete my question... I'm a bit embarrassed.

Upvotes: 0

Omar Tariq
Omar Tariq

Reputation: 7724

global $wpdb;
if($events = $wpdb->get_results("SELECT post_id FROM wp_postmeta WHERE meta_value = 'frontpage';" )){
                    print_r($events);
}

Upvotes: 1

Related Questions