WordPress.org

Ready to get started?Download WordPress

Forums

Empty category and custom permalink issue (11 posts)

  1. himed
    Member
    Posted 6 years ago #

    Hi,

    I'm having an issue with custom permalinks and category pages that I cannot figure out. When I have custom permalinks on and you click on a category that does not contain any posts, you get a 'Error 404 - Not Found' page. With permalinks set to default you get category.php which is what I want. I think it may have something to do with the rewrite rules but I'm not familiar enough with these to know what I'm doing. Anyone know why you would get a 404 for an empty category only when custom permalinks are on?

    Thanks - Joe

  2. donderhaas
    Member
    Posted 6 years ago #

    I had a similar issue, maybe you'll also find the solution here - all I had to do was change the permissions on my htaccess file. Here's the post - http://wordpress.org/support/topic/108996?replies=10

  3. himed
    Member
    Posted 6 years ago #

    Thanks but I don't think that is the problem. I say this because when the custom permalinks are on, I do not get 404 from categories that contain posts, only empty categories. So .htaccess is being updated, but for some reason clicking on an empty category produces a 404 error. Any other ideas?

  4. moshu
    Member
    Posted 6 years ago #

    Since it doesn't find any posts in an empty category - it will show the "no post found" message. Whate else do you expect in an empty cat?

    Furthermore, show me an example when the category.php is being displayed for empty.

  5. himed
    Member
    Posted 6 years ago #

    No, it's not displaying a 'no posts found' message, it's redirecting to the 404.php page in my theme dir. This is my category.php code:

    <?php get_header(); ?>
    
    	<div id="content">
    
    		<h2 class="pagetitle">Archive for the ‘<?php single_cat_title(); ?>’ Category</h2>
            <?php  $cat_title = single_cat_title("", false);
    			   $cat_id = get_cat_ID($cat_title);
    			   echo "<ul>";
    			   wp_list_categories('orderby=name&hide_empty=0&title_li=&child_of=' . $cat_id);
    			   echo "</ul><br />"; ?>
         </div>
    
    <?php get_footer(); ?>

    So basically I'm showing the category title and then listing the child categories. When using the default permalink structure I get this page even for empty categories, but when I switch to custom permalinks, only categories containing a post show this code. Empty categories show a 'Error 404' message which is what I'm trying to fix. Make sense?

  6. Tefra
    Member
    Posted 6 years ago #

    yeap, i am having the same problem.

  7. Ben Welch-bolen
    Member
    Posted 6 years ago #

    Still having same problem, if you hide categories is set to 0 wordpress should know not to show a 404 for those, kinda annoying. Searched all over and no real fixes to actually serve an empty category page.

  8. iridiax
    Member
    Posted 6 years ago #

    If you don't want empty categories to be listed, remove &hide_empty=0 from wp_list_categories. Zero for hide_empty means false, so empty categories are NOT hidden. The default is to hide them.

  9. slobizman
    Member
    Posted 5 years ago #

    Same problem here. I want empty categories to show, but not get the 404 message. I want them to show since my blog is new and want people to see what categories are available for guest bloggers to post in.

    Simply put, if no posts exist in a category, I need to to simply show "No posts in category", but this cannot happen since it first does not find the page.

  10. acqu13sce
    Member
    Posted 5 years ago #

    I was having the same trouble and found the following forum post solved the problem. I didn't want to have to edit the core WordPress files but I couldn't find any other solution. One difference to note is that in v2.6.2 the line is 295 in wp-includes/classes.php

    http://wordpress.org/support/topic/33805?replies=8#post-378560

    Many thanks to the original poster of the solution, hope this link helps other people out too as long as you don't mind making the change each time you upgrade.

  11. msmeritt
    Member
    Posted 5 years ago #

    Thanks for referring us to that solution -- it worked perfectly!!

Topic Closed

This topic has been closed to new replies.

About this Topic