Hello...
I want to show an empty category page with 'there are no posts' if the category is empty instead of a 404 error.
Can someone PLEASE help me?
Hello...
I want to show an empty category page with 'there are no posts' if the category is empty instead of a 404 error.
Can someone PLEASE help me?
I'm not sure if this is the same thing, but if I can't do that... is there a way of doing something like:
if (is_category('3') && $posts == 0) { echo 'there are no posts'; }
Can anyone help? I put this in a category template, and it still shows a 404 error on empty category.
I've tried putting the code for categories into a page template, and then putting that into a static page, but it shows the date, title, edit link and posted by info.
I've tried putting the code for categories into a page template,
Don't do that. Pages are not for categories.
For categories use Category_Templates
I've looked through the documentation, and can't find a way to do this. I want to cry :(
In my category.php the Loop ends like this:
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
and that's the text displayed when a category is empty.
(It's true, I don't have a 404 page in the theme folder)
if you want this situation to happen in all the 404 situations, you can simply use the 404.php and duplicate the file you want to replicate in it, like the archive.php or category.php depending on the theme you use...
moshu... I tried deleting the 404.php but the text I put there, doesn't show up, and nor does a php snippet.
hi nexia
hi othellobloke, but did you understand my suggestion at least ???... i think i posted it wrong.. lol
I understood what you mean for sure, but that will give me that page on ANY 404 error.
I've found out how to fix a 404 error showing on empty category page.
In wp_includes/classes.php look for the line that starts with:
if ( (0 == count($wp_query->posts)) && !is_404() && !is_search()
and add the following after !is_404():
&& !is_category()
Then what I did was create category-1.php, category-2.php etc and put a custom message on each page.
This topic has been closed to new replies.