0

I have 4 read more urls in my woocommerce product listing and i would like all to be directed to a custom page instead of the product info page - preferably using functions.php

0

You could use the post_link filter to rewrite the permalinks for those selected products.

function redirect_products( $url, $post ) {

    if ( in_array($post->ID, array(1,2,3,4) ) { //1,2,3,4 = your product IDs
        $url = get_permalink(123); //the ID of the redirect page 
    }
    return $url;
}
add_filter( 'post_link', 'redirect_products', 10, 2 );
  • This almost works thanks. Can I do it based upon category instead? get_the_category? – Remco Jul 9 '18 at 4:55

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.