Skip to main content
Better formatting
Source Link
Pieter Goosen
  • 55.4k
  • 23
  • 115
  • 209

If you have Unknown column 'wp_postmeta.meta_key'wp_postmeta.meta_key in 'wherewhere clause

youYou probably want to join $wpdb->postmeta$wpdb->postmeta table into this query:

function custom_posts_join($join){
     global $wpdb;

     $join .= " LEFT JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id ";

     return $join;
}
add_filter( 'posts_join' , 'custom_posts_join');

If you have Unknown column 'wp_postmeta.meta_key' in 'where clause

you probably want to join $wpdb->postmeta table into this query:

function custom_posts_join($join){
     global $wpdb;

     $join .= " LEFT JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id ";

     return $join;
}
add_filter( 'posts_join' , 'custom_posts_join');

If you have Unknown column wp_postmeta.meta_key in where clause

You probably want to join $wpdb->postmeta table into this query:

function custom_posts_join($join){
     global $wpdb;

     $join .= " LEFT JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id ";

     return $join;
}
add_filter( 'posts_join' , 'custom_posts_join');
Source Link

If you have Unknown column 'wp_postmeta.meta_key' in 'where clause

you probably want to join $wpdb->postmeta table into this query:

function custom_posts_join($join){
     global $wpdb;

     $join .= " LEFT JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id ";

     return $join;
}
add_filter( 'posts_join' , 'custom_posts_join');