Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter fradway

    (@fradway)

    Thanks,

    I’ve found a solution that works pretty well for my specific situation. I used WordPress’s built in functionality using the author tag. Woocommerce doesnt replace the %author% like seen with standard WordPress posts so a simple string replace did the job.

    // replace %author%
    
    add_filter( 'post_type_link', 'wpse_post_type_link', 20, 2 );
    
    function wpse_post_type_link( $permalink, $post ) {
        if ( 'product' === $post->post_type && false !== strpos( $permalink, '%author%' ) ) {
            $author = get_the_author_meta( 'user_nicename', $post->post_author );
            $permalink = str_replace( '%author%', $author, $permalink );
        }
    
        return $permalink;
    }
Viewing 1 replies (of 1 total)