I have custom post type venue and custom taxonomy 'facility' and 'types', is it possible to generate custom permalinks for the single post and archive with current posts taxonomy slug. Example:

single post term facility slug is 'restaurant'


archive page


My custom post declaration

$args = array(
  'label'                 => __( 'Venue', 'weera' ),
  'description'           => __( 'Dubai day Venue listings', 'weera' ),
  'labels'                => $labels,
  'supports'              => array( 'title', 'excerpt', 'author', 'thumbnail', 'revisions'),
  'hierarchical'          => false,
  'public'                => true,
  'show_ui'               => true,
  'show_in_menu'          => true,
  'menu_position'         => 5,
  'menu_icon'             => 'dashicons-palmtree',
  'show_in_admin_bar'     => true,
  'show_in_nav_menus'     => true,
  'can_export'            => true,
  'has_archive'           => true,
  'exclude_from_search'   => false,
  'publicly_queryable'    => true,
  'capability_type'       => 'page',
  'rewrite' => array( 'slug' => 'restaurant'),
  'has_archive' => true,
register_post_type( 'venue', $args );

My taxonomy 'facility' declaration

$args = array(
  'labels'                     => $labels,
  'hierarchical'               => true,
  'public'                     => true,
  'show_ui'                    => true,
  'show_admin_column'          => true,
  'show_in_nav_menus'          => true,
  'show_tagcloud'              => true,
  'rewrite' => array( 'slug' => 'venue' ),

register_taxonomy( 'facility', array( 'venue' ), $args );

but http://mywebsite.com/restaurants and http://mywebsite.com/restaurant/restaurant-name both gives 404 pages.

  • did you save permalinks? Oct 4, 2016 at 7:04

1 Answer 1


You need to either go into Settings -> Permalinks and click Save

Or if you're doing this programmatically you need to use flush_rewrite_rules(), but make sure this is only used when you activate/deactivate the plugin, DON'T set this in code that runs (like in init, or on every page load):


register_deactivation_hook( __FILE__, 'flush_rewrite_rules' );
register_activation_hook( __FILE__, 'wdocs_flush_rewrites' );

 * Flush rewrite rules on activation
function wpdocs_flush_rewrites() {
    // call your CPT registration function here (it should also be hooked into 'init')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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