Hidden Custom Post Type

If you want it to be visible everywhere (i.e. search), just without the admin menu, then something to the effect of the following should do the trick when added to functions.php in the theme directory: register_post_type( ‘project’, array( ‘labels’ => array( ‘name’ => _x( ‘Projects’, ‘post type general name’, ‘namespace’ ), ‘singular_name’ => _x( ‘Project’, … Read more

Trigger renewal order emails for WooCommerce subscriptions for testing

To trigger an off-schedule renewal and therefore trigger the renewal order email, please follow these steps: Purchase the test subscription with either Stripe or a gateway that requires manual renewal payments (e.g. Cheque, Bank transfer). PayPal won’t work. Find the subscription key for the newly purchased subscription. Delete the wcs_blocker_{$user_id}_($subscription_key} transient from the database (where … Read more

Why was my plugin rejected from the WordPress.org repository?

This is because you directly call a PHP file from within your plugin folder. This is bad for two reasons, the first being that some people block direct access to PHP files inside the wp-content folder. The second is you need to include wp-load.php to access the WordPress API. Instead of linking to… site_url().””.”/wp-content/plugins/Printer-Friendly-WP/print.php?id=page_id=”.””. get_the_ID()` … Read more

Woocommmerce show SKU in cart page

Add the following code to your theme’s functions.php file, or as a new plugin: add_filter( ‘woocommerce_in_cart_product_title’, ‘add_sku_in_cart’, 20, 3); function add_sku_in_cart( $title, $values, $cart_item_key ) { $sku = $values[‘data’]->get_sku(); return $sku ? $title . sprintf(” (SKU: %s)”, $sku) : $title; }

Getting the Product object in a custom loop

You could use a custom query to fetch the product object. Here is a snippet to get the stock count. Take a look at the product class: http://docs.woothemes.com/wc-apidocs/class-WC_Product.html for functions available for the product object. <?php $args = array( ‘post_type’ => ‘product’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’, ‘tax_query’ … Read more

Reposition Woocommerce Message

WooCommerce renders messages by using woocommerce_show_messages() function. This function is hooked to woocommerce_before_single_product action. So if you don’t want to render messages before single product, you need to remove that hook for the action. remove_action( ‘woocommerce_before_single_product’, ‘woocommerce_show_messages’ ); If you want to render messages in another place, then just call woocommerce_show_messages() function in desired place.