Complex meta query with 3 keys

The culprit The culprit of the matter is meta queries not supporting different and/or nested relations – a shortcoming by the way, that has driven me nuts before as well. In a recent instance with a search scenario also. What you want to do simply cannot be accomplished with WP_Query as well as one loop … Read more

Two WordPress sites sharing the same content

If your main requirement is to synchronise blog posts from a master site to a slave, then maybe look at the FeedWordPress plugin. It means that you would only add/edit posts on one website and they would be replicated to the other site. That will allow you to cleanly run different plugins on the two … Read more

wpdb->insert multiple record at once

$wpdb->query(“INSERT INTO settings-table (option_name, option_value, option_created, option_edit, option_user) VALUES (‘name-1’, ‘val-1’, current_time(‘mysql’), current_time(‘mysql’), ‘user-1’), (‘name-2’, ‘val-2’, current_time(‘mysql’), current_time(‘mysql’), ‘user-2’), (‘name-3’, ‘val-3’, current_time(‘mysql’), current_time(‘mysql’), ‘user-3′)”) In the query which you had posted, the column names shouldn’t be in string.

Connect to database using wordpress wp-config file

Using the defines the user sets in wp-config: mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); EDIT: Since your script is outside the WordPress environment, what you want to do is initiate it before using the defines in wp-config. require_once(‘./path/to/the/wp-config.php’); mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);

Count & Display Database Queries

You can paste this block of code in your currently active WordPress theme functions.php file: function wpse_footer_db_queries(){ echo ‘<!– ‘.get_num_queries().’ queries in ‘.timer_stop(0).’ seconds. –>’.PHP_EOL; } add_action(‘wp_footer’, ‘wpse_footer_db_queries’); The above block of code, will render an HTML comment in the footer of your theme (before </body> and </html>, containing the number of database queries and … Read more