Beautify Feed URL for custom post type

Question

I have news custom post type and I use this URL to check the news feed

http://website.com/feed/?post_type=news

Is There a way to change it to :

http://website.com/news/feed/

<?php
function news_post_type()
{

    $labels = array(
      ....
    );
    $rewrite = array(
        'slug' => 'news',
        'with_front' => true,
        'pages' => true,
        'feeds' => true,
    );
    $args = array(
        'label' => __('News', 'HCT_text_domain'),
        'description' => __('News Post Type', 'HCT_text_domain'),
        'labels' => $labels,
        'supports' => array('title', 'thumbnail', 'editor', 'revisions', 'page-attributes', 'category', 'tag'),
        'taxonomies' => array('news_categories', 'category', 'tag'),
        'hierarchical' => false,
        'public' => true,
        'show_ui' => true,
        'show_in_menu' => true,
        'menu_position' => 5,
        'show_in_admin_bar' => true,
        'show_in_nav_menus' => true,
        'can_export' => true,
        'has_archive' => true,
        'exclude_from_search' => false,
        'publicly_queryable' => true,
        'rewrite' => $rewrite,
        'show_in_rest' => true,
     
    );
    register_post_type('news', $args);

}

add_action('init', 'news_post_type', 0);
0
Ahmed 4 months 0 Answers 11 views 0

Leave an answer