Advertisement
wclovers

Untitled

Jul 31st, 2023 (edited)
904
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.39 KB | None | 0 0
  1. function custom_product_permalink($permalink, $post) {
  2.     // Check if the post is a product and has the product post type
  3.     if (is_object($post) && $post->post_type === 'product') {
  4.         // Build the custom permalink
  5.         $permalink = add_query_arg( 'product_id', $post->ID, $permalink );
  6.     }
  7.  
  8.     return $permalink;
  9. }
  10. add_filter('post_type_link', 'custom_product_permalink', 10, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement