Reputation: 10061
I have created the custom post type guides
in wordpress. So, I can see all the posts of guides
under the URL: http://example.com/guides/
. When I click to see the detail view of any post of guides, the URL structure has been http://example.com/guides/any-post-of-guide/
. Here I just want: for all guides, the url should have guides and for the single post of guide, the url structure should have guide (instead of guides). Can you tell me someone how to do this.
The code below what I have done and tried:
$args = array(
'labels' => $labels,
'description' => __( 'Description.', 'your-plugin-textdomain' ),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => 'ml-vault.php',
'query_var' => true,
'rewrite' => array( 'slug' => 'guides'),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title','editor', 'excerpt', 'thumbnail')
);
Upvotes: 2
Views: 2129
Reputation: 2471
rewrite
argument to:'rewrite' => array('slug' => 'guide', 'with_front' => false),
add_action('init', function()
{
add_rewrite_rule('^guides/?$', 'index.php?post_type=guides', 'top');
});
Upvotes: 1
Reputation: 1
Have you reconsidered the argument rewrite in your args array? More about rewrite here - https://codex.wordpress.org/Function_Reference/register_post_type#rewrite
Upvotes: 0