How to find exact match for search term in WP_Query? What is the additional string added in LIKE query in WP_Query?

it adds additional value before and after each Like query That {d146fc7cb41ff444163abadd50ac5da7ec5439fd51386c3cfe2cea107126703b} is a placeholder escape string for the literal % (percent) sign used in prepared statements (see wpdb::prepare()) and the escape string is generated by wpdb::placeholder_escape(). So actually, that {d146fc7cb41ff444163abadd50ac5da7ec5439fd51386c3cfe2cea107126703b} is the % sign, but in an escaped form, and it will be changed … Read more

Adding new row to wp_post table

First, I assume you’re referring to columns, not rows. To answer your question, no, the upgrade process will not remove the extra columns from the posts table. That said, WordPress has the wp_postmeta table that should be used to store extra data about posts rather than adding columns to the posts table. I would suggest … Read more

Disallow categories from this MySQL query

You could use the get_tax_sql() function introduced in WP 3.1: $tax_query = array( array( ‘taxonomy’ => ‘category’, ‘terms’ => array( 4, 6, 7, 9 ), ‘operator’ => ‘NOT IN’ ) ); $clauses = get_tax_sql( $tax_query, $wpdb->posts, ‘ID’ ); … “SELECT ID, post_date, post_date_gmt, comment_status, comment_count FROM $wpdb->posts {$clauses[‘join’]} WHERE post_status=”publish” AND post_type=”post” {$clauses[‘where’]} ” … … Read more

Join new table with SQL query

Always escape/prepare your data Don’t leave it open to injections: global $wpdb; $all_posts = $wpdb->get_results( $wpdb->prepare( ” SELECT %s.* FROM %s LEFT JOIN %s ON(%s = %s) WHERE %s=”soundcloud” AND %s=”%s” ” ,$wpdb->posts ,$wpdb->posts ,”{$wpdb->prefix}soundcloud” ,$wpdb->posts.ID ,”{$wpdb->prefix}soundcloud.idpost” ,$wpdb->posts.post_type ,$wpdb->posts.post_name ,$name ), OBJECT ); echo ‘<pre>’.var_export( $all_posts, true ).'</pre>’; Use the prefix $wpdb; offers the $wpdb->prefix, … Read more