2

Okay So I'm facing a weird problem as i'm receiving 404 errors on blog category and tag pages. I'm using custom theme which includes:

  • tag.php
  • category.php
  • archive.php
  • home.php
  • index.php and
  • 404.php.

The Blog archive is working fine but when i try to load tag pages or category pages i'm being redirected to 404.php template file.

Also there is one other weird problem which i'm facing if i remove 404.php file from my theme folder the category and tag links are working fine and loads content from archive.php but it shows page not found on page title and error404 class is added inside the body tag of that page.

Here is the list of items that i've tried so far to solve the issue:

  1. Refreshed Permalink Structure.
  2. Applied Category and Tag Base.
  3. Changing the theme to twentyseventeen in which everything was fine
  4. All the code in my header and footer.php file follows wordpress theme guidelines.

Please suggest me a solution that might help to solve this as it works fine without 404.php. The Blogs and Categories on website are imported from other website using Wordpress importer.

Question Update: Why Does Wordpress redirects to 404.php even tough files category.php, archive.php and index.php are present inside Wordpress theme folder on category or tag pages ??

  • this is something to do with your theme or plugins. It is unlikely that anyone here will be able to just guess what is wrong. You need to actually debug what is going on in your tag/category templates and why redirection (if it is a redirect and not a simple load) happens. – Mark Kaplun Feb 2 '18 at 6:56
  • Hi Mark, I've disabled all plugins as well, also it works if I change the theme or remove 404.pho file. But if I remove 404 file it shows error in wordpress title but shows all related blogs by category or tag. That's why it's weird I cannot understand how to solve it as I need 404.php file in my theme – Vatsh Patel Feb 2 '18 at 7:29
  • so its a problem with your theme, without seeing its code it will be hard to know the cause – Mark Kaplun Feb 2 '18 at 7:31
  • All the code in header and footer is calling basic wordpress functions like wp_head and wp_footer and wp_nav_menu. No extra functions are called. Also as per wp codex it should use category.php template file so can it be some issue in wordpress 4.9 as I've updated wordpress straight after installing wordpress – Vatsh Patel Feb 2 '18 at 7:35
  • You see the 404 template because the requests are resulting in a 404. If 404.php is not present, then it falls back to using index.php template. Are you visiting a tag or category that contains posts? If yes, then you have code somewhere in your theme that is modifying the main query resulting in no posts being returned. – Milo Feb 3 '18 at 4:12
0

please set permalinks

enter image description here

then after check in category and tag url

  • 1
    Hi Dharmishtha, please read the question again I've tried that already – Vatsh Patel Feb 2 '18 at 7:27
-2

Go to your WordPress back-end with this path Settings > Permalinks. Ensure that the base of the category is "category" and the tag is the base "tag" (unless you have some very strange special settings) and just press the "Save Changes" button even if nothing has changed, clicking on the button may cause your category and tag pages to work again.

Don’t forget to clean your WordPress cache for testing.

  • 1
    Hi vishal please read the question again I've tried that already. – Vatsh Patel Feb 2 '18 at 7:28
  • Can you please share your website so I can check it. – vishalprajapati13 Feb 2 '18 at 7:39
  • macrisondev.com.au – Vatsh Patel Feb 2 '18 at 7:40
  • I did check in console and found one error. "Uncaught TypeError: Cannot read property 'getContext' of null" Can you please closed the canvas mark correctly. – vishalprajapati13 Feb 2 '18 at 8:00
  • Yes I noticed that as well but the canvas partial was just called in file frontpage.php we are not calling it anywhere else on the website. Also the whole HTML Dom itself is not loading instead it is redirected to 404.php page – Vatsh Patel Feb 2 '18 at 8:01

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.