0

Before you say this is a duplicate of another question please hear me out.

I have a custom post type on a site I'm building.

When adding pagination to the page (domain.com/news) it gives me a 404 error when trying to view anything other than the first page (domain.com/news/page/2/).

BUT... if I create a test page (domain.com/test), add the same news feed there and also add the pagination it works perfectly! (domain.com/test/page/2/).

Puzzling... I can't workout what's different between the two pages.

I've tried saving permalink settings to flush the cache there, have flushed the site cache, have tried various mods to rewrite rules in functions.php but nothing has worked.

Any thoughts or ideas?

Thanks in advance,

Tom

5
  • What is /news? The post type archive? Do you have a Page (post type page) with the slug news? "add the same news feed there" - how did you add it? Using a custom WP_Query?
    – Sally CJ
    Jan 14, 2022 at 16:01
  • '/news' is the URL of the News page. I've created a page in Wordpress called 'News', then created a template called 'page-news.php' and added a custom WP_Query there as you say. The really strange thing is that it works on a test page ('/test' created in the same way) but not on '/news'? Any idea why? Is Wordpress trying to do something with '/news' by default? Jan 18, 2022 at 10:27
  • No, it's not. Do you have any (custom) post type where the has_archive is set to news (so the archive would be accessible at example.com/news)? Because if so, then it's possible for /news/page/2 to display a "Nothing here" (i.e. a 404) page. However, if that's the case, then you would have noticed it when viewing the 1st page.. are you sure the template being loaded is indeed page-news.php?
    – Sally CJ
    Jan 18, 2022 at 10:56
  • It definitely was 'page-news.php' being loaded. I've got around it by changing the URL of the news section to be '/newsfeed' rather than '/news' which works perfectly. Very puzzling indeed! Thanks for your help Sally CJ Jan 19, 2022 at 9:27
  • It's my pleasure, but if and when you have the time, you should try to find out what's causing the problem - maybe some code in the active theme or a plugin. (you could try deactivating plugins - if that solves the problem, then just activate the plugins back 1 at a time until the problem reappears)
    – Sally CJ
    Jan 19, 2022 at 10:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.