Disable (or limit) queries when certain content (or data) is not needed (or showed)

You can filter ‘posts_fields’, check if it is the main query and limit the queried fields to … whatever you need. See WP_Query::get_posts() in /wp-includes/query.php for details and side effects. For debugging the queries I recommend the plugin Debug Bar. If you add … define( ‘WP_DEBUG’, TRUE ); define( ‘SAVEQUERIES’, TRUE ); … to your … Read more

Creating and Using Tables in the WordPress Database

The requirements you’ve specified don’t indicate any need for a custom post table. Just register a custom post type using register_post_type(), and then manipulate its entries using the standard WordPress API. Example from the codex, registering a ‘book’ custom post type with a label of “Books”: function my_init() { $args = array( ‘public’ => true, … Read more

Get post featured image id with $wpdb

Haven’t tested it, but this should work: SELECT $wpdb->posts.ID, $wpdb->posts.post_title, $wpdb->terms.name, wpcflat.meta_value AS latitude, wpcflong.meta_value AS longitude, 6371 * 2 * ASIN ( SQRT (POWER(SIN(($lat – wpcflat.meta_value)*pi()/180 / 2),2) + COS($lat * pi()/180) * COS(wpcflat.meta_value *pi()/180) * POWER(SIN(($long – wpcflong.meta_value) *pi()/180 / 2), 2) ) ) AS distance, wpcfthumbnail AS thumbnail_id; FROM $wpdb->posts LEFT JOIN … Read more

wpdb update multiple row?

Your code of wpdb method is correct. posible reasons why it fails… you have only one user that match’s meta_key = ‘user_token’ other functionality change query at query hook filter strage. debug the final SQL with add_filter( ‘query’, ‘query_report’, 10000 ); function query_report($sql){ var_dump($sql); return $sql; }

WordPress $wpdb no result

Your specific issue in that code is that you’re missing the quote marks around the $code. $query .= ‘WHERE code=”.$code; Should be: $query .= “WHERE code= “‘.$code.'”‘; In the long run, you should indeed use prepare() properly, but this is the specific problem with the code you posted.

$wpdb->prepare error after WordPress update [duplicate]

Because you’re missing second argument, for more information see this post – http://make.wordpress.org/core/2012/12/12/php-warning-missing-argument-2-for-wpdb-prepare/. Also you’re doing it wrong, for security reason you shouldn’t pass variables into query directly that’s why you should use prepare() method – see Codex for usage info.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)