Custom post type redirect in WordPress

add_action( 'template_redirect', 'aviweb_redirect_post_type' );
function aviweb_redirect_post_type() {
	$queried_post_type = get_query_var('post_type');
	if ( is_single() && 'custom_post' ==  $queried_post_type ) {
		$redirection_url = get_site_url() . '/custom_page';
		wp_redirect( $redirection_url, 301 );
	exit;
	}		
}
Advertisements

Get WooCommerce order information like billing, shipping & date.

$order_id = 1234;
$order_data = new WC_Order($order_id);

//Order Date
$order_date = $order_data->order_date;    

//Billing information 
$billing = $order_data->get_address('billing'); 

//Shipping information 
$shipping = $order_data->get_address('shipping');