daily pastebin goal
32%
SHARE
TWEET

WooCommerce - Do shortcode after given category

lorro Mar 17th, 2017 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.   // WooCommerce - Do shortcode after given category
  3.   add_action( 'woocommerce_after_main_content', 'my_action' );
  4.   function my_action() {
  5.     if (is_product_category()) {
  6.       global $wp_query;
  7.       $cat = $wp_query->get_queried_object();
  8.       $cat_id = $cat->term_id;
  9.       switch ($cat_id) {
  10.         case 21: // my category id
  11.           echo do_shortcode('[product id="1801"]');
  12.           break;
  13.         default:
  14.       }    
  15.     }
  16.   }
RAW Paste Data
Top