posts_join (ok)
function custom_posts_join($join){
global $wpdb;
if( is_user_logged_in()){
// $join .= " LEFT JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id ";
}
echo '<pre>';
var_export($join);
echo '</pre>';
return $join;
}
add_filter( 'posts_join' , 'custom_posts_join');
Add posts_join
function custom_posts_join($join){
global $wpdb;
if( is_user_logged_in()){
$join .= " LEFT JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id";
}
echo '<pre>';
var_export($join);
echo '</pre>';
return $join;
}
add_filter( 'posts_join' , 'custom_posts_join');
==== Default ====
" "
" "
" "
==== Add posts_join ====
" LEFT JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id"
" LEFT JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id"
" LEFT JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id"
==== Default var_export($wp_query); ====
WP_Query::__set_state(array(
'query' =>
array (
'post_status' => 'publish',
'post_type' => 'wp_template',
'posts_per_page' => -1,
'no_found_rows' => true,
'tax_query' =>
array (
0 =>
array (
'taxonomy' => 'wp_theme',
'field' => 'name',
'terms' => 'twentytwentyone',
),
),
'post_name__in' =>
array (
0 => 'search',
),
),
'query_vars' =>
array (
'post_status' => 'publish',
'post_type' => 'wp_template',
'posts_per_page' => -1,
'no_found_rows' => true,
'tax_query' =>
array (
0 =>
array (
'taxonomy' => 'wp_theme',
'field' => 'name',
'terms' => 'twentytwentyone',
),
),
'post_name__in' =>
array (
0 => 'search',
),
'error' => '',
'm' => '',
'p' => 0,
'post_parent' => '',
'subpost' => '',
'subpost_id' => '',
'attachment' => '',
'attachment_id' => 0,
'name' => '',
'pagename' => '',
'page_id' => 0,
'second' => '',
'minute' => '',
'hour' => '',
'day' => 0,
'monthnum' => 0,
'year' => 0,
'w' => 0,
'category_name' => '',
'tag' => '',
'cat' => '',
'tag_id' => '',
'author' => '',
'author_name' => '',
'feed' => '',
'tb' => '',
'paged' => 0,
'meta_key' => '',
'meta_value' => '',
'preview' => '',
's' => '',
'sentence' => '',
'title' => '',
'fields' => '',
'menu_order' => '',
'embed' => '',
'category__in' =>
array (
),
'category__not_in' =>
array (
),
'category__and' =>
array (
),
'post__in' =>
array (
),
'post__not_in' =>
array (
),
'tag__in' =>
array (
),
'tag__not_in' =>
array (
),
'tag__and' =>
array (
),
'tag_slug__in' =>
array (
),
'tag_slug__and' =>
array (
),
'post_parent__in' =>
array (
),
'post_parent__not_in' =>
array (
),
'author__in' =>
array (
),
'author__not_in' =>
array (
),
'ignore_sticky_posts' => false,
'suppress_filters' => false,
'cache_results' => true,
'update_post_term_cache' => true,
'lazy_load_term_meta' => true,
'update_post_meta_cache' => true,
'nopaging' => true,
'comments_per_page' => '50',
),
'tax_query' =>
WP_Tax_Query::__set_state(array(
'queries' =>
array (
0 =>
array (
'taxonomy' => 'wp_theme',
'terms' =>
array (
0 => 'twentytwentyone',
),
'field' => 'name',
'operator' => 'IN',
'include_children' => true,
),
),
'relation' => 'AND',
'table_aliases' =>
array (
),
'queried_terms' =>
array (
'wp_theme' =>
array (
'terms' =>
array (
0 => 'twentytwentyone',
),
'field' => 'name',
),
),
'primary_table' => NULL,
'primary_id_column' => NULL,
)),
'meta_query' =>
WP_Meta_Query::__set_state(array(
'queries' =>
array (
),
'relation' => NULL,
'meta_table' => NULL,
'meta_id_column' => NULL,
'primary_table' => NULL,
'primary_id_column' => NULL,
'table_aliases' =>
array (
),
'clauses' =>
array (
),
'has_or_relation' => false,
)),
'date_query' => false,
'post_count' => 0,
'current_post' => -1,
'in_the_loop' => false,
'comment_count' => 0,
'current_comment' => -1,
'found_posts' => 0,
'max_num_pages' => 0,
'max_num_comment_pages' => 0,
'is_single' => false,
'is_preview' => false,
'is_page' => false,
'is_archive' => true,
'is_date' => false,
'is_year' => false,
'is_month' => false,
'is_day' => false,
'is_time' => false,
'is_author' => false,
'is_category' => false,
'is_tag' => false,
'is_tax' => true,
'is_search' => false,
'is_feed' => false,
'is_comment_feed' => false,
'is_trackback' => false,
'is_home' => false,
'is_privacy_policy' => false,
'is_404' => false,
'is_embed' => false,
'is_paged' => false,
'is_admin' => false,
'is_attachment' => false,
'is_singular' => false,
'is_robots' => false,
'is_favicon' => false,
'is_posts_page' => false,
'is_post_type_archive' => false,
'query_vars_hash' => 'ca7de00678c7ac484be6ea28f736883d',
'query_vars_changed' => false,
'thumbnails_cached' => false,
'stopwords' => NULL,
'compat_fields' =>
array (
0 => 'query_vars_hash',
1 => 'query_vars_changed',
),
'compat_methods' =>
array (
0 => 'init_query_flags',
1 => 'parse_tax_query',
),
))
WP_Query::__set_state(array(
'query' => array(
'post_status' => 'publish',
'post_type' => 'wp_template',
'posts_per_page' => -1,
'no_found_rows' => true,
'tax_query' => array(
0 => array(
'taxonomy' => 'wp_theme',
'field' => 'name',
'terms' => 'twentytwentyone',
),
),
'post_name__in' => array(
0 => 'search',
),
),
'query_vars' => array(
'post_status' => 'publish',
'post_type' => 'wp_template',
'posts_per_page' => -1,
'no_found_rows' => true,
'tax_query' => array(
0 => array(
'taxonomy' => 'wp_theme',
'field' => 'name',
'terms' => 'twentytwentyone',
),
),
'post_name__in' => array(
0 => 'search',
),
'error' => '',
'm' => '',
'p' => 0,
'post_parent' => '',
'subpost' => '',
'subpost_id' => '',
'attachment' => '',
'attachment_id' => 0,
'name' => '',
'pagename' => '',
'page_id' => 0,
'second' => '',
'minute' => '',
'hour' => '',
'day' => 0,
'monthnum' => 0,
'year' => 0,
'w' => 0,
'category_name' => '',
'tag' => '',
'cat' => '',
'tag_id' => '',
'author' => '',
'author_name' => '',
'feed' => '',
'tb' => '',
'paged' => 0,
'meta_key' => '',
'meta_value' => '',
'preview' => '',
's' => '',
'sentence' => '',
'title' => '',
'fields' => '',
'menu_order' => '',
'embed' => '',
'category__in' => array(
),
'category__not_in' => array(
),
'category__and' => array(
),
'post__in' => array(
),
'post__not_in' => array(
),
'tag__in' => array(
),
'tag__not_in' => array(
),
'tag__and' => array(
),
'tag_slug__in' => array(
),
'tag_slug__and' => array(
),
'post_parent__in' => array(
),
'post_parent__not_in' => array(
),
'author__in' => array(
),
'author__not_in' => array(
),
'ignore_sticky_posts' => false,
'suppress_filters' => false,
'cache_results' => true,
'update_post_term_cache' => true,
'lazy_load_term_meta' => true,
'update_post_meta_cache' => true,
'nopaging' => true,
'comments_per_page' => '50',
),
'tax_query' =>
WP_Tax_Query::__set_state(array(
'queries' => array(
0 => array(
'taxonomy' => 'wp_theme',
'terms' => array(
0 => 'twentytwentyone',
),
'field' => 'name',
'operator' => 'IN',
'include_children' => true,
),
),
'relation' => 'AND',
'table_aliases' => array(
),
'queried_terms' => array(
'wp_theme' => array(
'terms' => array(
0 => 'twentytwentyone',
),
'field' => 'name',
),
),
'primary_table' => NULL,
'primary_id_column' => NULL,
)),
'meta_query' =>
WP_Meta_Query::__set_state(array(
'queries' => array(
),
'relation' => NULL,
'meta_table' => NULL,
'meta_id_column' => NULL,
'primary_table' => NULL,
'primary_id_column' => NULL,
'table_aliases' => array(
),
'clauses' => array(
),
'has_or_relation' => false,
)),
'date_query' => false,
'post_count' => 0,
'current_post' => -1,
'in_the_loop' => false,
'comment_count' => 0,
'current_comment' => -1,
'found_posts' => 0,
'max_num_pages' => 0,
'max_num_comment_pages' => 0,
'is_single' => false,
'is_preview' => false,
'is_page' => false,
'is_archive' => true,
'is_date' => false,
'is_year' => false,
'is_month' => false,
'is_day' => false,
'is_time' => false,
'is_author' => false,
'is_category' => false,
'is_tag' => false,
'is_tax' => true,
'is_search' => false,
'is_feed' => false,
'is_comment_feed' => false,
'is_trackback' => false,
'is_home' => false,
'is_privacy_policy' => false,
'is_404' => false,
'is_embed' => false,
'is_paged' => false,
'is_admin' => false,
'is_attachment' => false,
'is_singular' => false,
'is_robots' => false,
'is_favicon' => false,
'is_posts_page' => false,
'is_post_type_archive' => false,
'query_vars_hash' => 'ca7de00678c7ac484be6ea28f736883d',
'query_vars_changed' => false,
'thumbnails_cached' => false,
'stopwords' => NULL,
'compat_fields' => array(
0 => 'query_vars_hash',
1 => 'query_vars_changed',
),
'compat_methods' => array(
0 => 'init_query_flags',
1 => 'parse_tax_query',
),
))
Last updated