Hi Currently in our wordpress our default permalink structure is
abc.com/%postname%-%post_id%.html
But for specific category I want different permalink structure
Ex: for Photos Category i want url structure as
abc.com/%post_id%.html
Current i am using the following code But it is not working
add_filter( 'post_link', 'custom_permalink', 10, 3 );
function custom_permalink( $permalink, $post, $leavename ) {
// Get the categories for the post
$category = get_the_category($post->ID);
if ( !empty($category) && $category[0]->cat_name == "Photos" ) {
$permalink = trailingslashit( home_url('/'.$post->ID .'.html' ) );
}
return $permalink;
}
But i am not getting different permalink structure for specific category posts. Please help me.
0 comments:
Post a Comment