Travel Tour – Tour Master – Add /blog/ to blog pages without affecting other url

Shared by our customer: Add /blog/ to blog pages without affecting other url (notion.site) 

1. Install & activate the Travel Tour child theme

2. Within cPanel file manager, copy the code below and paste into public_html > wp-content > themes > traveltour-child > functions.php. Add the code after the existing code on teh file but before ‘/// END ENQUEUE PARENT ACTION’

3. Go to the WordPress website and settings > permalinks and select ‘Plain’ and save.

4. Now select ‘custom structure’, paste in /blog/%postname%/ and save.

5. You may need to refresh but it should work.

// Custom URL Blog
function create_tour_post_type() {
    register_post_type('tour',
        array(
            'labels' => array(
                'name' => __('Tours'),
                'singular_name' => __('Tour')
            ),
            'public' => true,
            'has_archive' => true,
            'rewrite' => array('slug' => 'tour', 'with_front' => false),
            'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments')
        )
    );
}
add_action('init', 'create_tour_post_type');
function create_destinations_post_type() {
    register_post_type('portfolio',
        array(
            'labels' => array(
                'name' => __('Destinations'),
                'singular_name' => __('Destination')
            ),
            'public' => true,
            'has_archive' => true,
            'rewrite' => array('slug' => 'destinations', 'with_front' => false),
            'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments')
        )
    );
}
add_action('init', 'create_destinations_post_type');

function create_personnel_post_type() {
    register_post_type('personnel',
        array(
            'labels' => array(
                'name' => __('Personnel'),
                'singular_name' => __('Person')
            ),
            'public' => true,
            'has_archive' => true,
            'rewrite' => array('slug' => 'personnel', 'with_front' => false),
            'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments')
        )
    );
}
add_action('init', 'create_personnel_post_type');
function create_room_post_type() {
    register_post_type('room',
        array(
            'labels' => array(
                'name' => __('Rooms'),
                'singular_name' => __('Room')
            ),
            'public' => true,
            'has_archive' => true,
            'rewrite' => array('slug' => 'room', 'with_front' => false),
            'supports' => array('title', 'editor', 'thumbnail', 'excerpt', 'comments')
        )
    );
}
add_action('init', 'create_room_post_type');