0

So I need to have page slug Blog before post title I used rewrite rule to achieve this but doing this resulting me in 404 errors for paginations the below is the code I used to rewrite.

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,
        'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'post-formats' ),
    ) );
}

This is the site URL Blog Page Rewrite is working good for this pages Single Post

but not for Pagination please guide me in solving this issue.

  • You're trying to use a built in post type name "post". That won't go well. – Andy Macaulay-Brook Aug 10 '16 at 12:27
  • @AndyMacaulay-Brook Then how will my requirement solved? – dh47 Aug 11 '16 at 1:29
-1

There are a number of reserved post type names in WordPress that you can't overwrite. They can be found on the codex:

https://codex.wordpress.org/Function_Reference/register_post_type

'post' is one of them.

  • I know how to override post function all i am asking here is 404 error in when I click pagination. – dh47 Aug 11 '16 at 1:28
  • @dh47 you can't create your own post type named 'post' – Alex Older Dec 19 '16 at 15:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.