url rewriting - How to change the url of the archive page to be inside the custom post type

admin2025-01-08  4

I made the custom post type named "News" and I have a static page load for url/news

Currently, the archive page loads with this url: url/?post_type=news

How do I make it so that the archive page will load using this url: url/news/all-news

Note: I'm using elementor

I made the custom post type named "News" and I have a static page load for url.com/news

Currently, the archive page loads with this url: url.com/?post_type=news

How do I make it so that the archive page will load using this url: url.com/news/all-news

Note: I'm using elementor

Share Improve this question asked Nov 19, 2024 at 8:26 PaulPaul 1
Add a comment  | 

1 Answer 1

Reset to default 2

The has_archive parameter for registering the post type should work (untested):

register_post_type( 'news', array(
    ...
    'has_archive' => 'news/all-news',
    'rewrite' => array(
        'slug'       => 'news',
        'with_front' => false,
    ),
) );

Remember to flush the permalinks by going to Settings > Permalinks and clicking Save button.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736268915a1312.html

最新回复(0)