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?
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/
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');
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.