Skip Navigation

[Resolved] I dont see how to add the id at the end of custom post type peramalink.

This support ticket is created 4 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 5 replies, has 2 voices.

Last updated by Shane 4 years ago.

Assisted by: Shane.

Author
Posts
#2157227
post id adding at permalink.PNG

I've set up custom post types like "job", I want a bit different permalink structure than the default. at the end of the permalink for the custom post type

I want something like:

domain.com / [custom_post_type] / [post-name] - [post-id]
domain.com /job/bank-recruitment/2365/

How can I achieve this? type of custom post type permalink. I don't see how to add the id at the end of the custom post type permalink.

#2157473

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hello,

Thank you for getting in touch.

The correct place to change this setting would be in Settings -> Permalinks as this is where you will add your permalink overwrite rule.

For this to only affect the Job post type you can try using the plugin below.
https://wordpress.org/plugins/custom-post-type-permalinks/

Please let me know if this helps.
Thanks,
Shane

#2157489
post id adding at permalink.PNG

HI

Shane

" Use a custom URL format " This option not working on my side, I don't want to go with any 3rd party plugins for custom permalink. already toolset provides the option like " Use a custom URL format", why I use another plugin. plz check once and conform me. " Use a custom URL format" future not working how to enable this.

#2157685

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hello,

The line below the field says "Optional. Prepend posts with this slug"

What this means is that any slug you add here will be used as the post type slug. This field doesn't accept placeholders such as %%POST_ID%% also it doesn't add the text here as a parameter only a slug that replaces the original CPT slug.

This field can't be used to achieve what you want hence the options are to modify the permalinks at Settings -> Permalinks or use a 3rd party plugin.

Thanks,
Shane

#2158181

Hi, Toolset Team (Shane) !

I want to place the post_id at the end of the custom post URL, so the URL will look like this

Domain.com/job/post_name/Post_id

So when I am looking for the solution I found some codes which are a little bit similar to my request. You can find that from the URL

Here is the Link: https://toolset.com/forums/topic/append-post_id-at-the-end-of-permalink-for-custom-post-type/.

add_filter( 'post_type_link', 'my_post_type_link', 10, 2 );
function my_post_type_link( $post_link, $post = null ) {
if ( !empty($post) ) {
return str_replace('%post_id%', $post->ID, $post_link);
}
}

The above code all works fine but I want a bit different permalink structure, But there is adding post id at the middle of the permalink but I want to add the end of the post for post id.

That code working like this below formate URL :

domain.com / [custom_post_type]/[post-id]/[post-name] = " domain.com / job/23567/ bank-recruitment/"

But I want Like This below URL formate:-

domain.com / [custom_post_type]/[post-name] /[post-id]/ = " domain.com / job/ bank-recruitment/23567/ ".

>>>>>>>>>>>>>>>>Please let me know if there is any solution for the above issue. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<

#2158493

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hello,

As I read in the post it doesn't seem to be possible because the link would result in an error 404 when the post ID is added to the end of the URL.

Based on this it only seems possible when the URL is added to the middle. However have you tried the plugin that I suggested as it appears to be able to allow you to extend the wordpress default permalink functions to your custom post types similar to how Woocommerce allows you to define a custom permalink structure for products.

Thanks,
Shane