Wpdb generates too many queries
Wpdb generates too many queries
Wpdb generates too many queries
The query itself may need to be optimized (SQL is not my speciality, though). However, don’t forget you can store the results of an expensive operation in cached memory. WordPress offers a Transients API to make things easy. Here’s a quick example: // Try to load the value from cache $transient_key = ‘my_query’; $value = … Read more
Custom WP_Query with SQL directives for getting posts by authors and terms
WP has Filesystem API to write files. However it can be relatively convoluted to implement (since it handles fallback for many cases and environments and workflow for requesting FTP crednetials from users) so often simply PHP functions are used to write file. Works reliably when constrained to uploads folder, otherwise need to be sure about … Read more
SQL query to remove first image in all posts
I would suggest to use double prefix like wp_hm_account, since it will allow you to recognize the tables (as you mentioned in comment) and you will be also able to use wpdb class properly.
strtotime is php function that can be used for this purpose. strtotime — Parse about any English textual datetime description into a Unix timestamp Firstly get all the posts using meta key . Then get date value from meta field. Then convert to unix timestamp. Then update again. $args = array( ‘posts_per_page’ => -1, ‘meta_key’ … Read more
I’m not sure why, but it had to do with the title in my ordering, once I removed that everything started working fine. I’ll leave this open for anyone who knows why. $query->set(‘orderby’, ‘meta_value_num title’); – Does not Work $query->set(‘orderby’, ‘meta_value_num’); – Works!
It’s the order of your primary key declaration. If you’re always searching on place_id, declare that first, then post_id: PRIMARY KEY (place_id, post_id)
You could insert a $wpdb->show_errors(); to output the errors in your query. Also you need to input that sql into dbDelta($sql) did you miss that?