Category: PHP

Reserved Terms in WordPress

Enable revisions for custom post type in WordPress

When you register custom post type, you have to add support for revisions. Title and text editor is the default support. if you want to enable revisions for your custom post type then you have to add like this.

'supports' => array( 'title', 'editor', 'revisions' ),

Add this code in your custom post type creation arguments array. for your information i listed available supports below.

1.'title'
2.'editor' 
3.'author'
4.'thumbnail' 
5.'excerpt'
6.'trackbacks'
7.'custom-fields'
8.'comments' 
9.'revisions' 
10.'page-attributes' 
11.'post-formats'

Have any doubt, then comment here!

Change the WooCommerce continue shopping URL in WordPress

If you want to change the WooCommerce continue shopping URL in WordPress, then place the place the following snippet in functions.php file within your theme folder!.

The WooCommerce continue shopping button will use your shop archive to send customers back to the shop page. The following code will redirect to home page when you click continue shopping button in your cart page.

function change_continue_shopping_button_url() {
	return site_url();	
}
add_filter( 'woocommerce_continue_shopping_redirect', 'change_continue_shopping_button_url' );

Have any doubt, then comment here!

Change the WooCommerce Return to shop URL in WordPress

For our customization want to change the WooCommerce Return to shop URL in WordPress then place the place the following snippet in functions.php within your theme folder!.

The WooCommerce Return to Shop button will use your shop archive to send customers back to the shop when the cart is empty. The following code will redirect to home page when you click Return to shop button in your empty cart page.

function change_empty_cart_button_url() {
	return site_url();	
}
add_filter( 'woocommerce_return_to_shop_redirect', 'change_empty_cart_button_url' );

Have any doubt, then comment here!

Get WooCommerce cart page URL programmatically

For our customization want to get WooCommerce cart page URL programmatically then use the following snippet!. The WooCommerce cart page URL can be retrieved with a call to the cart object’s get_cart_url() function.

global $woocommerce;
$cart_url = $woocommerce->cart->get_cart_url();

Have any doubt, then comment here!