wpdb query with sql expression
-
Hi
I’m trying to retrieve a list of year/months that have posts, such as generated by get_archives.
here is my function, it seems it doesn’t work because of the expression or parentheses, I’m not sure.
the sql statement is valid, and the function works if I remove the expression and just select the field.function do_post_dates(){ global $wpdb; $query = $wpdb->escape("SELECT distinct concat(monthname(post_date), ' ', year(post_date) FROM wp_posts;"); print $query; $post_dates = $wpdb->get_results($query); return $post_dates; }
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘wpdb query with sql expression’ is closed to new replies.