Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with 404 page #24

Open
dhananjaygbhardwaj opened this issue Jun 26, 2022 · 1 comment
Open

Issue with 404 page #24

dhananjaygbhardwaj opened this issue Jun 26, 2022 · 1 comment

Comments

@dhananjaygbhardwaj
Copy link

dhananjaygbhardwaj commented Jun 26, 2022

Hello Bill,

Let me start by thanking you for this starter theme. It has been a huge part of my learning curve towards WordPress theme development.

I recently came across a weird issue while working on an ongoing project. I couldn't report with a live URL for now, but I was able to reproduce the same behavior over at your personal website.

As an example, let's take this specific page: https://www.billerickson.net/favicon-dark-mode/

Simply right click any image within the content and open it in a new tab.

Remove the image's file extension from the address bar of the browser and hit enter.

Such as, from this:
https://www.billerickson.net/wp-content/uploads/2021/07/dark-mode.jpg

To this:
https://www.billerickson.net/wp-content/uploads/2021/07/dark-mode

This should (in my opinion) return a 404 error (it does get a 404 response from the server) and use the theme's inc/archive-none.php partial to display the default not found message.

However, to my surprise, it returns a page with a list of posts.

2022-06-26 16_28_10-Page Not Found - Bill Erickson — Mozilla Firefox (Private Browsing)

I am not entirely sure if it's an issue or intended behavior.

@billerickson
Copy link
Owner

That's interesting. It seems like the subdirectories in the URL change how WP runs its query.

https://www.billerickson.net/asdf
is_404() = true and has_posts() = false

https://www.billerickson.net/asdf/asdf
is_404() = true and has_posts() = false

https://www.billerickson.net/wp-content/uploads/asdf
is_404() = true and has_posts() = true

Inside ea_default_loop() we only check if has_posts() to run the loop. If no posts exist, we check if this is a 404 or an empty search query.

I'll dig in more later to figure out why this isn't working as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants