Skip Navigation

[Resolved] How to show parent/child custom post's slug in permalink

This support ticket is created 5 years, 9 months 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 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by Luo Yang 5 years, 9 months ago.

Assisted by: Luo Yang.

Author
Posts
#1288243

Hi,

I would like my permalink to show relationship between custom posts.

For example: hidden link
or specifically: hidden link

How do I do that?

#1288325

Hello,

There isn't such a built-in feature within Toolset Types plugin, the default WordPress permalink structure for custom post types are below:
hidden link
hidden link
...
hidden link
hidden link
...

In your case, it needs custom codes, for example,
https://codex.wordpress.org/Rewrite_API/add_rewrite_rule
add_rewrite_rule() allows you to specify additional rewrite rules for WordPress. It is most commonly used in conjunction with add_rewrite_tag() (which allows WordPress to recognize custom post/get variables).

And according to our support policy, we don't provide custom codes support:
https://toolset.com/toolset-support-policy/

You can also check it with our Toolset contractors:
https://toolset.com/contractors/

#1290381

Thanks. As far as toolset is concerned, how do put a custom parent post variable in the code so it can pull the correct one?

function custom_rewrite_basic() {
add_rewrite_rule('^country/city/?', 'index.php?post_id=$matches[1]', 'top');
}
add_action('init', 'custom_rewrite_basic');

#1291285

Within Toolset Types plugin, you can get related parent post ID with function toolset_get_related_post(), see our document:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_post

Then use it to get related parent post name:
https://developer.wordpress.org/reference/functions/get_post/

For your reference.