2

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 ?

enter image description here

1

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' );
1

you can use this plugin to generate this kind of permalink https://wordpress.org/plugins/wp-category-permalink/

0

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.

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.