Since I am only selling one single product with WooCommerce, I would like to delete the shop base. I have already deleted the page "shop" which WooCommerce automatically sets up when installing, but you can still reach the shop base page by typing .../shop.
I know in order to deactivate it completely, I need to set line 264 to false: https://github.com/woothemes/woocommerce/blob/master/includes/class-wc-post-types.php#L264
I am very new to programming though, can someone tell me how to do this?
Add the following code to your child theme's functions.php file
add_action( 'template_redirect', 'redirect_shop' );
function redirect_shop() {
if( is_shop() ) {
//replace the link below to point to your single product page
header('location:http://www.example.com/');
exit;
}
}
the you do not need archieve.php
template in your site, so can restrict this template to be executed and as @Anand Shah has said you can also display content if ( !is_shop() )
, that means when the page is not shop.how you want it to be done , that matters, there is a lot of ways to do this.
Just a few lines above the line you referenced, you can see that all the arguments for registering the product post type are sent through the woocommerce_register_post_type_product
filter, which means that you can modify any of the values. To disable the shop
archive you need to set has_archive
to false from a new plugin or your theme's functions.php (less ideal).
add_filter( 'woocommerce_register_post_type_product', 'so_32921498_product_post_type_args' );
function so_32921498_product_post_type_args($args){
$args['has_archive'] = false;
return $args;
}