0

Custom post edit page permalink links to edit page rather than the post

Here is how the Recipe custom post was created

  register_post_type( 'recipe',
  array(
    'labels' => array(
    'name' => __( 'Recipe' ),
    'singular_name' => __( 'Recipe' )
    ),
  'public' => true,
    'publicly_queryable' => true,
    'show_ui'  => true,
    'show_in_menu' => true,
  'query_var' => true,
    'rewrite' => array( 'slug' => '','with_front' => true ),
  'capability_type' => 'post',
    'has_archive' => true,
    'hierarchical' => false,
    'menu_position' => null,
  'taxonomies' => array( 'category' ),
  'supports' => array('title', 'editor', 'post-formats','comments','set_featured_image','thumbnail', 'excerpt', 'comments','custom-fields'),
  'capabilities' => array(
    'edit_post' => 'edit_recipes',
    'edit_posts' => 'edit_recipes',
    'edit_others_posts' => 'edit_other_recipes',
    'delete_posts' => 'delete_recipes',
        'delete_others_posts' => 'delete_other_recipes',
         'publish_posts' => 'publish_recipes',
    'read_post' => 'read_recipes',
    'read_private_posts' => 'read_private_recipes',
    'delete_post' => 'delete_recipes'
  )
  )
   );

  flush_rewrite_rules();
}

Please see the below screenshot of what I mean, how can I fix that?

enter image description here

4
  • Try setting 'rewrite' => false where you register the CPT, then unregister_post_type, then re-register the CPT. It's likely a problem with setting a rewrite then setting slug to empty.
    – WebElaine
    Commented Oct 25, 2017 at 13:34
  • @WebElaine setting it to false disabled the link prntscr.com/h1umta
    – loliki
    Commented Oct 25, 2017 at 13:54
  • You could try giving it a slug instead of setting it to empty.
    – WebElaine
    Commented Oct 25, 2017 at 15:16
  • I don't see any reason to have this: flush_rewrite_rules(); is that a shortcut around visiting the permalinks page after initializing the post type?
    – admcfajn
    Commented Oct 26, 2017 at 3:23

0

Your Answer

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

Browse other questions tagged or ask your own question.