jeudi 1 janvier 2015

Add SKU to Woocommerce custom post type URL


This is what I need:


http://ift.tt/1zCpiTm


With the code I found here, I do get the following solution:


http://ift.tt/14fucxR


Anybody has an idea how to remove the slash between postname and sku?



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 );




Aucun commentaire:

Enregistrer un commentaire