Hi,
I use the following code to add a sku to the end of all products urls. However, it breaks the permalinks for the events, not showing any link both on the front end or back end to the specific event. Can you suggest why this breaks and a way to solve it?
Here is the website: https://www.richardjuzwin.com.au
Here is the events page: https://www.richardjuzwin.com.au/events/
Here is the link to a product showing the sku on the end of the URL: https://www.richardjuzwin.com.au/product/sg-21dc-kgv-2/?sku=26900
Have added an image to this post where can see the event permalink is empty.
function append_sku_string( $link, $post ) {
$post_meta = get_post_meta( $post->ID, ‘_sku’, true );
if ( ‘product’ == get_post_type( $post ) ) {
$link = $link . ‘?sku=’ .$post_meta;
return $link;
}
}
add_filter( ‘post_type_link’, ‘append_sku_string’, 1, 2 );