Advertisement
majeedraza

WooCommerce - Do shortcode after given category

Mar 17th, 2017
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.45 KB | None | 0 0
  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.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement