admin管理员组文章数量:1122846
I use this code in Wordpress (Woocommerce) to change products link:
function jpb_custom_meta_permalink( $link, $post ){
$post_meta = get_post_meta( $post->ID, '_sku', true );
if( empty( $post_meta ) || !is_string( $post_meta ) )
$post_meta = '';
$link = str_replace( '!!custom_field_placeholder!!', $post_meta, $link );
return $link;
}
add_filter( 'post_link', 'jpb_custom_meta_permalink', 10, 2 );
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 );"
This code changes products permalink to something like this:
But what I want is:
Any suggestion?
本文标签: Woocommerce products permalink based on SKU
版权声明:本文标题:Woocommerce products permalink based on SKU 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736301823a1931310.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论