0
votes

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:

  • meta_id = 32765
  • post_id = 4376
  • meta_key = frontpage
  • meta_value = frontpage

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?

2
have you enabled WP_DEBUG mode to see errors? Maybe some errors are being displayed? - Omar Tariq
JUST enabled DEBUG - checking through errors there... - David McClave
Another check: Have you globalized $wpdb? like: global $wpdb;? - Omar Tariq
Not sure the problem is related, (not sure HOW it could be), but I get an error Trying to get property of non-object in E:\blahblahblah\wp-content\themes\Trailmeister\functions\taxonomies.php on line 81 - David McClave
Which line is the line 81? - Omar Tariq

2 Answers

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

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.