Please see an image below:
I’ve created 2 custom post types they called automaker and car-line (1 automaker has many car-line). I want to when I create new car-line post, the permalink will get value is selected of automaker and change it from http://myhost.com/aotungchao/doi-xe/corrola/ to http://myhost.com/aotungchao/mua-ban-oto/toyota/corrola/ (it means that change doi-xe to mua-ban-oto/toyota). Do the same with change select automaker option. How can I do that?
In order the get the url structure you are after, I would suggest using the built in wordpress categories.
For example:
Parent Category = Cars; Child Category = Toyoto; Post title = Corolla
Would give you a url of
categories/cars/toyota/corolla/
To remove the categories part, go to settings->permalink and place
./
in as the category name. Doing that will remove categories and give you a url that looks like the following:http://www.sitename.com/cars/toyota/corolla
.You can also create a custom taxonomy for car brands and assign that to your cars custom post type. See http://codex.wordpress.org/Taxonomies – look for Custom Taxonomies. Going this route will allow you to set a custom slug as well.