Wp query show post by author name or post title or post content

I hope this would do, i have not tested it. Test it on your own risk, but the query related to it very closely. function kv_get_custom_search_query($search_text){ global $wpdb; $wpdb->get_results( “SELECT * FROM $wpdb->posts WHERE post_title=”%$search_text%” OR post_content=”%$search_text%” OR post_title=”%$search_text%” LEFT JOIN $wpdb->users ON $wpdb->posts.post_author=$wpdb->users.ID AND display_name=”%$search_text%””); }

$wpdb select all meta for each post

This is really simple. get_post_meta($postid); This will return all values in about the same syntax. In a more workable loop: <?php $custom = new WP_Query(array(“posts_per_page” => -1)) if( $custom->have_posts() ) { while ( $custom->have_posts() ) { the_post(); $data = get_post_meta(get_the_ID()); } } else { /* No posts found */ } ?>

UPDATE on SELECT results. A SQL query to swap Author with Meta Box value

I always find it way less confusing to get the results from one table and loop them rather than to try to join them like that… eg. global $wpdb; $query = “SELECT post_id FROM wp_postmeta WHERE meta_key=’fake_author’ AND meta_value=”11111″”; $results = $wpdb->get_results($query); foreach ($results as $result) { $query = “UPDATE wp_posts SET post_author=”222222″ WHERE ID='”.$result->post_id.”‘”; … Read more