1
votes

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.

2
Surely this should be on Superuser? - Samir Talwar
No... I'm not asking for help with a simple configuration of WordPress. There's obviously a coding issue here and I've got no problem writing custom PHP in themes or plugin so long as it doesn't override core files. - philfreo

2 Answers

0
votes

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.

0
votes

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.