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


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: