Support » Plugins » WP custom post types pagination/404 error

  • I’m using a custom post type in WordPress (called “ns_news_article” generated from Magic Fields) which are registered and working. This rewrites the URL to add “category/news” after the domain (so: I have to have the “fake directories” in there.

    I have this in the functions.php:

    add_rewrite_rule("[ns_news_article]" . '$', "index.php?pagename=[ns_news_article]", "top");
    add_rewrite_rule("[ns_news_article]" . '/page/([0-9])*/?', "index.php?pagename=[ns_news_article]" . '&paged=$matches[1]', "top");
    global $wp_rewrite;

    The 2nd line takes care of pagination 404 problem when viewing as multiple pages of lists, but then gives 404 errors when trying to view the single post. If I get rid of this, you can view the posts, but pagination doesn’t work.

    Can I fix this or should it be done another way?

Viewing 1 replies (of 1 total)
  • Hello there – having a sim liar problem but my rule is loading the archive page when it should load single.php. Is ?pagename= only for pages? Any idea what it would be for a post? ?postname= doesn’t seem to work.

    best, Dan,

Viewing 1 replies (of 1 total)
  • The topic ‘WP custom post types pagination/404 error’ is closed to new replies.