Query WooCommerce orders grouped by several order statuses

The documentation on wc_get_orders and WC_Order_Query is poor… Now regarding the order status in a WC_Order_Query, you can pass an array of order statuses: // Display “completed” orders count $statuses = [‘completed’]; $orders = wc_get_orders( [‘limit’ => -1, ‘status’ => $statuses] ); echo ‘<p>’ . sprintf( __(‘Count of “%s” orders: %s’), implode(‘”, “‘, $statuses), count($orders) … Read more

Place page title in header?

If you only need the title you can request it outside the loop easily. Try and call the_title() in your header. It should work But you have to be aware that if you don’t put a condition, each page of your website will display its title in the header section. EDIT: the function to call … Read more

Remove Woocommerce product link

The way I’ve done this was to take a copy of content-product.php and paste it into the root of your theme folder. Comment out do_action( ‘woocommerce_before_shop_loop_item_title’ ); and do_action( ‘woocommerce_after_shop_loop_item’ ); Quick and dirty, but it worked for me.

Why would a GET variable one one page of a site cause a 404 error when a GET variable works on another page of a site?

WordPress has a list of reserved terms that you cannot use for taxonomies. From your question, I gather that “cooked” is a taxonomy that applies to eggs and “type” is a taxonomy that applies to sausage. Unfortunately, “type” is a reserved term in WordPress, so it interprets your query string differently than you expect. The … Read more

How to validate WordPress generated password in DB using PHP?

Based on your other question … it sounds like you’re trying to validate a given plaintext password against what’s stored in the database. Here’s the function WordPress uses to do just that: function wp_check_password($password, $hash, $user_id = ”) { global $wp_hasher; // If the hash is still md5… if ( strlen($hash) <= 32 ) { … Read more

$wpdb->delete column values IN ARRAY()?

No, wpdb::delete does not handle anything other than WHERE field = X. You can just use the query method instead: $ids = implode( ‘,’, array_map( ‘absint’, $ids ) ); $wpdb->query( “DELETE FROM table_name WHERE ID IN($ids)” );

How to check if feed URL was requested?

You have not specified exactly when your code runs but you can hook into “request” to check the requested page: add_filter( ‘request’, function( $request ){ if( isset( $request[‘feed’] ) ){ //This is a feed request } return $request; }); When the requested page is a feed $request, which is an array of query variables, will … Read more

Remove Customize Background and Header from Appearance admin menu without CSS or JS

As overcomplicated as it sounds, I always find the best way to handle admin menu modifications is to overlook the given wordpress remove_ functions and go straight to the $menu and $submenu globals. In the case you’ve specified here, you’d want to change your code to: add_action(‘admin_menu’, ‘remove_unnecessary_wordpress_menus’, 999); function remove_unnecessary_wordpress_menus(){ global $submenu; unset($submenu[‘themes.php’][20]); unset($submenu[‘themes.php’][22]); … Read more