Add Store name in coupon url in PremiumPress coupon theme

Add this to functions.php to the themes folder:

[php]function obs_add_store_to_permalink( $post_link, $post ){
if ( is_object( $post ) && $post->post_type == ‘listing_type’ ){
$terms = wp_get_object_terms( $post->ID, ‘store’ );
if( $terms ){
return str_replace( ‘%store%’ , $terms[0]->slug , $post_link );
}else{ return str_replace( ‘%store%’ , ‘store’ , $post_link );
}
}
return $post_link;
}
add_filter( ‘post_type_link’, ‘obs_add_store_to_permalink’, 1, 2 );[/php]

Then add %store%/ before the existing Listing Slug Name like %store%/coupon in the Permalink Setting

You are done !

Let me know if you have any problems.

Spread the love