How to count number of records found in a database table?

Why don’t you directly echo the $num as it will contain the count of rows already…Here’s the edited part.. //To show number of rows in table function DB_Tables_Rows() { global $wpdb; $table_name = $wpdb->prefix . ‘mydata’; $count_query = “select count(*) from $table_name”; $num = $wpdb->get_var($count_query); echo $num . ‘Rows Found’; }

Add few specific post ids to wp_query

Here is another way of doing it, specially if you need to work with the query object. The issue with merging queries is that you loose the correctness of the query object. My idea here is to run two separate queries, one very lean one to get post ID’s from the date_query query and then … Read more

How to change bulk post status

Yes, it’s possible to loop all publish posts and change their post status to draft. add_action(‘admin_init’,’wpse_244394′); function wpse_244394(){ $args = array(‘post_type’=> ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’=>-1 ); $published_posts = get_posts($args); foreach($published_posts as $post_to_draft){ $query = array( ‘ID’ => $post_to_draft->ID, ‘post_status’ => ‘draft’, ); wp_update_post( $query, true ); } }

view queries made?

See this codex page. in wp-config.php: define(‘SAVEQUERIES’, true); then in your template: if (current_user_can(‘administrator’)){ global $wpdb; echo “<pre>”; print_r($wpdb->queries); echo “</pre>”; } or without the above SAVEQUERIES, you can still see just the main query: global $wp_query; echo $wp_query->request; or to see all of $wp_query: <pre> <?php print_r($wp_query); ?> </pre>