Tag Info

Hot answers tagged

5

There is no build in function to achieve what you want, at least not for complicated meta queries like this. If you need to use build in functions for this, the best will be to make use of WP_Query. To make the query faster and to skip the unwanted returned array of WP_Post properties, and because you are only interested in post count, you can use the ...


2

The problem you are having is that get_queried_object returns results based on the query that was run. On author.php, the queried object was an author. On single.php, page.php, or any custom post type template, the queried object will be the post, not the author. This means that if you want to use $wp_query->get_queried_object();, you will have to be ...


2

There's not a one-to-one relationship between the WordPress database and the .wxr file. We can find this line in the exported .wxr file: <!-- This file is not intended to serve as a complete backup of your site. --> Skimming through the export_wp() function, we can see what's excluded, for example: The data stored in the wp_options table isn't ...


2

replace will only replace a row if one of the column values you supply is a primary key or unique index, and that value is identical to an existing row. If your table has neither a primary key or unique index, it will always only insert new rows. You will have to first query for existing data to decide if something should be deleted and a new row inserted. ...


1

Your AJAX callback method should be outputting something followed by a die() statement. function wp_insert() { ..your code echo $whatever_your_results_are; // die(); } I would also recommend against prefixing your custom methods with wp_. That should be reserved for WordPress and will cause confusion to other developers - and probably you ...


1

You can't use wpdb::prepare to inject table names - just use "SELECT ... $sidebar_table"


1

You Can use This solution.. How to delete all records from or empty a custom database table? In this solution First delete all records an then insert new records (your table should be have records before to delete query because If run $delete you give error 'No find row' ) and No need to use replace I us insert add this following query before your ...


1

Of course! I just had to set the $accepted_args parameter of add_filter() to 2. Like so: add_filter('posts_join', 'my_join', 10, 2); function my_join($join, &$query) { echo $query->is_main_query() ? 'y' : 'n'; return $join; }


1

Make sure you have declared the $wpdb variable global $wpdb;. Also calling $wpdb->query() will execute the query for you, so no need to do it again. I would also recommend using $wpdb->insert() as this escapes your data for you: global $wpdb; $wpdb->insert( $wpdb->prefix . 'fafa', array( 'titile' => trim( ...


1

The following code will properly store data in wp_fafa: $wpdb->insert( $wpdb->prefix . 'fafa', array( 'title' => trim($row->item(0)->nodeValue), 'liveprice' => trim($row->item(2)->nodeValue), 'changing' => trim($row->item(4)->nodeValue), 'lowest' => ...


1

The output that you posted above is expected behaviour for $wpdb->print_error() if the following is true - You are running a single site, not multisite $wpdb->suppress_errors is set to false $wpdb->show_errors is set to false From the looks of your code, you meet all those conditions. Note also that, unless you have turned them off previously, ...



Only top voted, non community-wiki answers of a minimum length are eligible