wordpresswoocommercepermalinks

Create product custom permalink in woocommerce


In Woocommerce Product page I have: H1, H2 (ACF field) and SKU Could I create generated automatically a product permalink with these 3 fields?

With this function I can display the product SKU, but I do not want the (#) in the url, just /SKUnumber:

function append_sku_string( $link, $post ) {

    $post_meta = get_post_meta( $post->ID , '_sku', true );

    if ( 'product' == get_post_type( $post ) ) {
        $link = $link . '#' .$post_meta;

        return $link;
    }
}
add_filter( 'post_type_link', 'append_sku_string', 1, 2 );

Solution

  • I found the Permalink Manager Pro plugin which is a perfect solution for my issue > https://permalinkmanager.pro/