admin管理员组文章数量:1323524
Is it possible to make custom URL path for pages ? The current page url is /insight which I need to show like /city/local/insight are any option in wordpress to customise the url ?
Is it possible to make custom URL path for pages ? The current page url is http://localhost.dev/insight which I need to show like http://localhost.dev/city/local/insight are any option in wordpress to customise the url ?
Share Improve this question asked Nov 23, 2016 at 13:53 MuhammedMuhammed 1471 silver badge8 bronze badges4 Answers
Reset to default 2you can use this plugin to generate this kind of permalink https://wordpress/plugins/wp-category-permalink/
It's probably best to register a new post type for this. In custom post types you can easily control the url structure. Use the register_post_type function for this.
In this function you can add a rewrite
variable. This variable controls the slug / url structure. Check out this example:
function insight_init() {
register_post_type( 'insight', array(
'labels' => array(),
'public' => true,
'hierarchical' => false,
'show_ui' => true,
'show_in_nav_menus' => true,
'supports' => array( 'title', 'editor' ),
'has_archive' => false,
'rewrite' => array('slug' => 'city/local')),
'query_var' => true,
'menu_icon' => 'dashicons-analytics',
) );
}
add_action( 'init', 'insight_init' );
For a page, you need to create a parent page(s) with the slug you want to put in between. Then you may choose these pages as a parent to the last slug page (insight page in your case). It will insert the needed slugs into your URL.
So you need to create /city page, then /local page and make /local child to /city page parent. then make /insight page child to /local parent.
Then you may change parent pages visibility to i.e. drafts or private. URL will be preserved.
The custom post type method mentioned is likely the superior one, but if you are not comfortable with registering a post type or using that code in a plugin of your own, there is a plugin that the WordPress codex recommends for this: WP Category Permalink.
This is part of the larger entry regarding using permalinks.
本文标签: How to inject custom url path for page
版权声明:本文标题:How to inject custom url path for page ? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742131849a2422197.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论