i am working on wordpress project that i have one diffuculty, i want to add "Blog" slug to blog posts
for example my current blog slug is like
http://www.abc.com/post
i want to make it like
http://www.abc.com/blog/post
i don't want to create custom post type i need to use existing ones
i have tried many solution such as changing permalinks to blog/%postname%
one solution worked for me
below is my code
add_action( 'init', 'my_new_default_post_type', 1 );
function my_new_default_post_type() {
register_post_type( 'post', array(
'labels' => array(
'name_admin_bar' => _x( 'Post', 'add new on admin bar' ),
),
'public' => true,
'_builtin' => false,
'_edit_link' => 'post.php?post=%d',
'capability_type' => 'post',
'map_meta_cap' => true,
'hierarchical' => false,
'rewrite' => array( 'slug' => 'blog' ),
'query_var' => false,
'with_front' => false,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'post-formats' ),
) );
}
i have added this code to my functions.php and added slug to posts. but problem came when i clicked on particular post it will redirected to 404 page. and if i remove this code it i will redirecting to correct post.
need your suggesions.