Modifying custom post type created by WooCommerce

I need to modify the product custom post type created by WooCommerce. Specifically, I’m trying to set query_var to false so that http://example.com/?post_type=product does not redirect to the product archive. For some reason the following doesn’t seem to work.

add_filter("woocommerce_after_register_post_type", "update_product_post_type");
function update_product_post_type() {
    $args = get_post_type_object("product");
    $args->query_var = false;
    register_post_type("product", $args);
}

Read more here: Modifying custom post type created by WooCommerce

Leave a Reply

Your email address will not be published. Required fields are marked *