SQL database export-import

backup only all tables you need from localhost so your .sql file contain only the tables you need & after this go to your live server keep your databse as it the use the following cmd from unix/linux SSH to keep the old tables & only restore the new tables mysql -u username -ppassword databasename … Read more

Get post by ASC from custome field DATE picker

So what you need to do is order it by the custom value of the meta_key date value. Something like this (untested): $wp_query = new WP_Query( array( ‘post_type’ => ‘upcoming_events’, ‘order’ => ‘ASC’, ‘meta_query’ => array ( array ( ‘key’ => ‘your_custom_date_key’, ‘value’ => date(‘Y-m-d’) ) ), ‘orderby’ => ‘meta_value’ ) ); Hope that helps.

Why doesn’t this code add a table to my database?

A key must be defined for a table by using a single column, or multiple. So on your code, you need to a line to the sql KEY id (id) – $sql = “CREATE TABLE $table_name ( id int NOT NULL AUTO_INCREMENT, feedurl text NOT NULL, category text NOT NULL, KEY id (id) );”;

WordPress database error – Error in SQL syntax – I can’t identify any error?

You want the query to look like this: SELECT email FROM wp_my_users WHERE email=”[email protected]” instead of this: SELECT email FROM ‘wp_my_users’ WHERE email=”[email protected]” So try to construct your query with: $sql = “SELECT email FROM {$my_table_name} WHERE email = %s”; $result = $wpdb->get_var( $wpdb->prepare( $sql, $email_address ) ); where you don’t need to escape the … Read more

Single meta_query query using OR instead of AND in request’s WHERE statement

I believe the shortest and best approach is to (1) modify the query: function search_faqs_metadata($query) { if(!is_admin() && $query->is_main_query()) { if($query->is_search) { $query->set(‘meta_query’, array(array( ‘key’ => ‘_faqs’, ‘value’ => $query->query_vars[‘s’], ‘compare’ => ‘LIKE’ ))); } } } add_action(‘pre_get_posts’, ‘search_faqs_metadata’); and then (2) replace the AND with OR via the get_meta_sql filter: function change_meta_key_where_from_and_to_or($sql) { if(is_search()) … Read more

You have an error in your SQL syntax – Help with query

If that is the error, a couple of things could be going on. The part that uses ‘require’, ‘require_once’ and ‘include’ is not likely correct in the code. Each of these code statements should end with a semi-colon [;] not a comma [,] hh3_ I expect is the table prefix initially used in your database. … Read more