I got it to work for one of my custom post.
I have a parent theme installed and I have modified it with a child-theme.
The parent theme creates a custom post type called Listings and I wanted to customise the permalink for this post type.
I installed this on the my WordPress multisite v4.3.1 and activated the plugin. It enables permalink customisation for all the custom post types found on the site. (See the screenshot on this plugin page).
Custom Post Registration
It is important to have has_archive
enabled for your custom post registration. The author of the plugin also suggests to enable the rewrite
argument. It worked for me even with the rewrite
parameter set to false
.
When you open your Settings->Permalink page in the Dashboard, you will see the values of the above 2 arguments displayed below the custom post permalink option field.
How to modify registration parameters?
In case you are using a child theme with the custom post declared in parent theme, it is best not to change the custom post registration code of the parent theme, but instead hook the following function in your ‘functions.php’ file.
add_action( 'registered_post_type', 'enable_rewrite_in_custom_post', 10, 2 );
function enable_rewrite_in_custom_post( $post_type, $args ) {
if ( 'listing' === $post_type ) { //change this to your custom post_type slug
global $wp_post_types;
$args->has_archive = true;
$args->rewrite->with_front = true;
$wp_post_types[ $post_type ] = $args;
}
}
Custom taxonomy terms in permalinks.
Once you have the custom post correctly registered, you can modify the permalinks for your custom post from your Dashboard page, Settings->Permalink, and add various dynamic options to the permalink.
For example, my custom post has a custom taxonomy labelled Types. In the Dashboard custom post menu, I can get this custom taxonomy slug from the taxonomy edit page url link. It is listing_type
.
I can then use this in the custom post permalink option field such as
/%listing_type%/%postname%/
which will build url links of the form,
https://<my domain name>/listing/<txonomy Types term slug>/<post slug>