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
-
You could try the excerpt_more filter.– user141080Jul 8, 2018 at 15:52
1 Answer
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?– RemcoJul 9, 2018 at 4:55