0

I'm working with custom post type, that I want to paginate, here's part of code, initializing custom post type:

$args = array(
        'labels'             => $labels,
        'public'             => false,
        'publicly_queryable' => true,
        'show_ui'            => true,
        'show_in_menu'       => true,
        'query_var'          => true,
        'capability_type'    => 'post',
        'has_archive'        => true,
        'hierarchical'       => false,
        'menu_position'      => null,
        'supports'           => array('title', 'page-attributes')
    );

    register_post_type( 'article', $args );

So, when url is /article I see first page of posts and there's no problem. paginate_links() function creates link to the second page /article/page/2, but it doesn't work - I have 404 error. This topic describes absolutely the same problem, but solution by Mark doesn't work for me. If I add 'rewrite' => array( 'slug' => 'artone') for example, url /article doesn't work at all, only /artone.

As I understand, method of printing my articles doesn't matter. When I search something about this problem, I can see only advices about query_posts, WP_query and so on. But is_archive() becomes false and is_404() becomes true even before header.php, so I don't know, where the problem can be, maybe something in functions.php.

Also, even if I set default permalinks ?p=123 url /?paged=2&post_type=article doesn't work!

P.S. I don't forget flushing rewrite rules

  • @PieterGoosen what do you mean? I've said, that it doesn't matter, I can even not display posts at all and problem will exist. Or I'm wrong? – lenden Jul 21 '15 at 12:32
  • Sorry, I slightly misread the question. Did you hook your code to init? – Pieter Goosen Jul 21 '15 at 12:36
  • @PieterGoosen do you mean post_type creation? of course, it works, there is also $labels and so on – lenden Jul 21 '15 at 12:37
1

1.Login as the admin in WordPress.

2.Go to the Settings tab.

3.Go to the Reading tab.

4.Change the Blog pages show at most from the default 10 to any number *less than 10. For example, 5.

5.Save the changes.

6.View the blog.

Hope that helps.

  • Perfect! I've totally forgot about default posts_per_page, I think I should change it in some hook or set in interface. Thank you very much! – lenden Jul 21 '15 at 12:50
  • @lenden if this worked, then you are using a custom query of some kind. – Pieter Goosen Jul 21 '15 at 12:52

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.