WordPress.org

Ready to get started?Download WordPress

Forums

clear archives of excluded categories (3 posts)

  1. vant
    Member
    Posted 1 year ago #

    Hi
    I'm excluding some categories in archive.php using this code ....

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    	<?php if (!in_category(23,10,17,14,11,13,12,7,28,22,29,27,26,21,16,15,19,20,25,18,24,8,9,33,32,34,35)) { ?>
        <h5><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a> &nbsp; <?php the_time('F j, Y'); ?></h5>
        <?php } ?>
    
      <?php endwhile;?>

    It seems to be half working. The months still show up in the archive widget and the highlighted days in the calendar. When I click on these links I get a blank white page. How can I destroy these links completely? I've tried resetting the permalinks but it did nothing.

    Thanks
    Mark

  2. bcworkz
    Member
    Posted 1 year ago #

    So the problem is the widgets are showing months and highlighting days related only to posts with categories that you wish to exclude?

    If so, you need to change the results the widgets see instead of just filtering what is sent out for the archive page. For the archive widget, it calls wp_get_archives(). You can alter the query used by hooking the filter 'getarchives_where'.

    For the calendar widget, it uses get_calendar(). Unfortunately, there is no handy filter to hook. The query is hard coded. The clean way to get your desired results is to create a custom version of get_calendar() and a custom calendar widget which would call your special version. Then replace the default calendar with your special one from the widgets admin panel. There's a dirty hack that is much easier, but a bad idea.

    The blank white page is the result of some PHP error, which hopefully will be a non-issue if you get rid of the offending links.

  3. vant
    Member
    Posted 1 year ago #

    Thanks.

    I'm not bothered about showing the Archive widget, but I'd like to have the calendar. I think I have two problems. First, the calendar is highlighting days that contain only posts from excluded categories. Second, the blank white pages. It looks like they're showing even if I click calendar days that contain posts from non-excluded categories, so I must have an error somewhere.

    I'm a WordPress beginner and to be honest I'm not sure where to start with your suggestions. I'll have to do a little studying.

    Thanks for the help.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.