• I’m quite new to PHP just completed a Codecademy course and still learning “isn’t the internet a wonderful thing” any how, I have put some PHP into my functions.php the problem is its executing site wide.

    The PHP is meant to run only for products in a specific category of woocommerce everything works just how do I tell wordpress “hey, only do this php for woocommerce products in category A”

    Here’s the code anyone know ?

    //Remove cart options from under short description.
    
    remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
    
    		//Filter below adds new tab and returns cart options within tab.
    
    add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
    function woo_new_product_tab( $tabs ) {
    	// Adds the new tab
    		$tabs['plans'] = array( 'title' => __( 'Price Plans', 'woocommerce' ), 'priority' => 50, 'callback' => 'woo_new_product_tab_content' );
    	return $tabs;
    }
    function woo_new_product_tab_content() {
    	// The new tab content
    		woocommerce_template_single_add_to_cart();
    } 
    
    	//Filter below changes tab priority to display price plans first.
    
    add_filter( 'woocommerce_product_tabs', 'sb_woo_move_description_tab', 98);
    function sb_woo_move_description_tab($tabs) {
    
    		$tabs['plans']['priority'] = 5;
    		$tabs['description']['priority'] = 10;
    		$tabs['reviews']['priority'] = 20;
    
    	return $tabs;
    }
  • The topic ‘How to Make PHP run "only" in specific Category’ is closed to new replies.