• Hi all!

    I’m having a quite strange issue on the front page of my WordPress powered website. When I list all the different categories using wp_list_cats() or wp_list_categories(), one of the main categories is marked as selected in the list (class=”current-cat”) even though I’m browsing the front page. How is this possible?

    Thanks for any replies.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Which one? The default?

    Thread Starter TheFixer

    (@thefixer)

    No, category 5, and it isn’t the default category.

    Thread Starter TheFixer

    (@thefixer)

    Okay, I tried to narrow the problem down, and it seems that this is causing the category to be marked as selected. Is there something wrong in the code perhaps?

    <?php query_posts('showposts=3&cat=5'); ?>
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
    <?php the_excerpt(); ?>
    <?php endwhile; ?>
    <?php endif; ?>

    ‘showposts=3&cat=5
    show 3 posts — from cat with the ID 5

    this means all of the 3 posts are only from cat 5 and so cat 5 is the selected cat

    it is logical

    regards
    Monika

    Thread Starter TheFixer

    (@thefixer)

    Yes, I guess it’s logical, but howcome it’s affecting the list which is outside the loop? Is there a way of getting around this?

    Thread Starter TheFixer

    (@thefixer)

    Just to give you guys an update, if ever there is anyone else with the same issue:

    I’m pretty amazed that I figured this out, even though I have no idea if this is a good “solution” or not. I simply added this snippet of code just before where the category list appears:

    <?php query_posts('cat=-0'); ?>

    Voilà!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Strange front page issue with wp_list_cats()’ is closed to new replies.