gp featured post excerpt length

// gp blog - featured post excerpt length
add_filter( 'excerpt_length', function( $length ) {
    global $wp_query;
    if ( 0 === $wp_query->current_post && !wp_is_mobile() ) {
        // Set Length of first post on desktop
        $length = 50;
    } else {
        // Set Length of other posts and all posts on mobile
        $length = 20;
    }
	return $length;
}, 200);

woo omit categories from shop

// woo - omit categories from shop page

add_filter( 'get_terms', 'ts_get_subcategory_terms', 10, 3 );
function ts_get_subcategory_terms( $terms, $taxonomies, $args ) {
$new_terms = array();
// if it is a product category and on the shop page
if ( in_array( 'product_cat', $taxonomies ) && ! is_admin() &&is_shop() ) {
foreach( $terms as $key => $term ) {
if ( !in_array( $term->slug, array( 'uncategorized', 'sessions', 'programs' ) ) ) { //pass the slug name here
$new_terms[] = $term;
}}
$terms = $new_terms;
}
return $terms;
}

woo autocomplete virtual orders

/**
 * Auto Complete all WooCommerce virtual orders.
 * 
 * @param  int 	$order_id The order ID to check
 * @return void
 */
function custom_woocommerce_auto_complete_virtual_orders( $order_id ) {

	// if there is no order id, exit
	if ( ! $order_id ) {
		return;
	}

	// get the order and its exit
	$order = wc_get_order( $order_id );
	$items = $order->get_items();

	// if there are no items, exit
	if ( 0 >= count( $items ) ) {
		return;
	}

	// go through each item
	foreach ( $items as $item ) {

		// if it is a variation
		if ( '0' != $item['variation_id'] ) {

			// make a product based upon variation
			$product = new WC_Product( $item['variation_id'] );

		} else {

			// else make a product off of the product id
			$product = new WC_Product( $item['product_id'] );

		}

		// if the product isn't virtual, exit
		if ( ! $product->is_virtual() ) {
			return;
		}
	}

	/*
	 * If we made it this far, then all of our items are virual
	 * We set the order to completed.
	 */
	$order->update_status( 'completed' );
}
add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_virtual_orders' );

woo product title above image

// woo - product title above image
function product_change_title_position() {
	remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
	add_action( 'woocommerce_before_single_product', 'woocommerce_template_single_title', 5 );
}
add_action( 'init', 'product_change_title_position' );

woo remove tabs on product page

//Remove WooCommerce Tabs - this code removes all 3 tabs - to be more specific just remove actual unset lines 
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
function woo_remove_product_tabs( $tabs ) {

    unset( $tabs['description'] );      	// Remove the description tab
    unset( $tabs['reviews'] ); 			// Remove the reviews tab
    unset( $tabs['additional_information'] );  	// Remove the additional information tab
    
    return $tabs;

}

woo cart change continue shopping button text

add_action('woocommerce_cart_actions', function() {
  ?>
  <a class="button wc-backward" href="<?php echo esc_url( apply_filters( 'woocommerce_return_to_shop_redirect', wc_get_page_permalink( 'shop' ) ) ); ?>"> <?php _e( 'Return to shop', 'woocommerce' ) ?> </a>
  <?php
});

woo products per page

//woo Change number of products that are displayed per page (shop page)

add_filter( 'loop_shop_per_page', 'new_loop_shop_per_page', 20 );
function new_loop_shop_per_page( $cols ) {
  // $cols contains the current number of products per page based on the value stored on Options –> Reading
  // Return the number of products you wanna show per page.
  $cols = 12;
  return $cols;
}