1

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. Adding the following to functions.php 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);
}

1 Answer 1

0

I think this hook fits your cause much better:

add_filter ('woocommerce_register_post_type_product', 'my_callback');
function my_callback ($args) {
     $args ['query_var'] = false;
     return $args;
}

not tested, but should work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.