Answer the question
In order to leave comments, you need to log in
How to properly set up CNC specific urls for custom post types in WP?
Hello.
Just started learning WP. The task is to collect a catalog of organizations with a complex structure, filtering, CNC.
I made a set of my own post types (via register_post_type) and created a couple of test posts.
Conditional pair of them
add_rewrite_rule(
"catalog/(ru|by|ua)/$",
'index.php?post_type=city', //&country=$matches[1]
"top"
);
#catalog/%country%/ - список городов
#catalog/%country%/%city%/ - список компаний, привязанных к конкретному городу
#catalog/%country%/%city%/%company%/ - конкретная компания
#catalog/%country%/%city%/filer_type/(ip|ooo)/ - вывод компаний отфильтрованных по типу ИП, ООО
#catalog/%country%/%city%/filer_vid/([a-z_\-]+)/ - вывод компаний с фильтром по виду деятельности
publicly_queryable
query_var
rewrite
add_rewrite_rule(
"^catalog/([a-z_\-]+)/$",
'index.php?post_type=city&country=$matches[1]',
"top"
);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question