Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
If the asker does not get an answer then they have 10 days to request a refund.
$10
Displaying blog with excluded categories in archive problem
I am using Wordpress 3 which has most of the coding in the loop.php file. I have tried adding a plugin to exclude categories and it has partially worked along with putting
<?php query_posts('cat=-6'); ?>at the top of loop.php
However the archive page does not seem to work correctly on the archives section, it displays everything in the date archive.
Here is the site in question I have removed the plugin and rolled it back to the standard way things are and it is still not showing the archive properly.
Site :
What I need an answer on is how to display a blog section with categories and archive but with some categories excluded ?
This question has been answered.
gunkdesign | 12/21/10 at 4:49pm
Edit
(6) Possible Answers Submitted...
See a chronological view of answers?
Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
-

Last edited:
12/21/10
4:54pmPippin Williamson says:Try this plugin: http://wordpress.org/extend/plugins/advanced-category-excluder/
-

Last edited:
12/21/10
5:01pm -

Last edited:
12/21/10
5:28pm -

Last edited:
01/01/11
3:33pmChris Bavota says:You can add a conditional tag on your archive.php file within the WordPress loop that ignores any post within that category. Or in the loop.php file if your theme is using it. Here is what it would look like in the appropriate place in the TwentyTen loop.php file.
<?php if(!in_category("6")) : ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<div class="entry-meta">
<?php twentyten_posted_on(); ?>
</div><!-- .entry-meta -->
<?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?>
<div class="entry-summary">
<?php the_excerpt(); ?>
</div><!-- .entry-summary -->
<?php else : ?>
<div class="entry-content">
<?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyten' ) ); ?>
<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
</div><!-- .entry-content -->
<?php endif; ?>
<div class="entry-utility">
<?php if ( count( get_the_category() ) ) : ?>
<span class="cat-links">
<?php printf( __( '<span class="%1$s">Posted in</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-cat-links', get_the_category_list( ', ' ) ); ?>
</span>
<span class="meta-sep">|</span>
<?php endif; ?>
<?php
$tags_list = get_the_tag_list( '', ', ' );
if ( $tags_list ):
?>
<span class="tag-links">
<?php printf( __( '<span class="%1$s">Tagged</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list ); ?>
</span>
<span class="meta-sep">|</span>
<?php endif; ?>
<span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
<?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
</div><!-- .entry-utility -->
</div><!-- #post-## -->
<?php comments_template( '', true ); ?>
<?php endif; ?>
You can read more about the conditional tag here:
Previous versions of this answer: 12/21/10 at 6:22pm
-

Last edited:
01/01/11
3:33pmPeter Michael says:Add a filter:
# Exclude categories | functions.php
function fd_remove_cat( $notused )
{
global $wp_query;
$wp_query->query_vars['cat'] = '-3';
}
add_action('pre_get_posts', 'fd_remove_cat' );
Also see http://codex.wordpress.org/Custom_Queries, section 'Category Exclusion'
HTH- 01/05/11 6:25pm
gunkdesign says:After using and selecting you as a partial winner I came across a problem with your solution.
Although this solution works perfectly on the front end in the admin under "Posts" the categories are also excluded. This isn't practical for my end user as they cannot then edit their posts (i am using the excluded categories to control other things like banners) themselves.
Is there anything I can change in the function to make it work on the front end queries only?
Thanks
- 01/05/11 6:25pm
-

Last edited:
12/22/10
1:30pmLucas Wynne says:To do this easy use this plugin! http://wordpress.org/extend/plugins/simply-exclude/. It's very customizable and great for customizing those posts displayed.
This question has expired.
Current status of this question: Completed
Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
If the asker does not get an answer then they have 10 days to request a refund.
