views:

282

answers:

3

Currently there is a bug in WordPress if you have a Posts Page set under:

Settings->Reading->A Static Page->Posts Page

If there are posts, than the page (e.g. with a slug called news) displays the post, and uses index.php from the theme.

But, with this configuration, if there are no posts, then it calls the theme's 404 page. This is definitely a bug, and has been submitted (Ticket #10822). It should be letting index.php show whatever it wants upon !have_posts(), but right now the page doesn't seem to be called at all.

My question is: is there a workaround for this bug without modifying core wp files? I'd be open to a plugin, theme changes, a custom page template, htaccess changes, etc.

A: 

I just performed a test for it. It isn't actually serving a 404, it's using index.php but since no posts are found so it falls outside of the have_posts(). Are you sure it's not a plugin or theme causing your issue? I tested this with the default theme on a base install of WordPress.

Matt Walters
A: 

Most theme files have as part of their WP loop a catch for no posts, i.e.:

<?php else : ?>
Sorry, but you are looking for something that isn't here.
<?php endif; ?>

That might be what you're seeing. You can use a custom page template without that text (leave the loop) for yoiur posts page. And try Reveal Template | coffee2code.com to find out what template file you're looking at.

songdogtech
No I've confirmed that the text that is showing up is the text of my 404.php, not the text that show in the `else` block after `if (have_posts())`.
philfreo
A: 

The problem we are having is that we post products on our website, and sometimes we remove them. They are posted, not hard pages, as some are from feeds. They appear in the search engines, and if a posted item is removed then the browser gets a "Not Found," and this is the problem: wehen an post is called, WordPress treats it as a search, and if it isn't there then the result is "Not Found" but not "Page Not Found." Therefore the status code is a 200 (OK) rather than a "404" and the search engine is not aware that the posted product is no longer there. This is completely unacceptable for ecommerce. Whoever wrote the routine was looking for a shortcut and decided to treat a request to a post as a query. That's fine, so long as a "404" and not a "200" is returned.

Michael Lee