Post Type Rewriting URL

Question

I’d like to add parameter /posts to custom post type posts.
Default post: /codechange to /posts/code
This code bellow automatically add /posts in admin part:

add_filter(
    'pre_post_link',
    function ($permalink, $post) {
        if ($post->post_type !== 'post') {
            return $permalink;
        }

        return '/posts/%postname%/';
    }, 10, 2
);

When i’ve visited /posts/code in website – page not found. How to fix this problem?

0
, , nikita Abramov 2 years 2019-12-01T21:25:46-05:00 0 Answers 79 views 0

Leave an answer

Browse
Browse