• Resolved wob

    (@wob)


    Hello,

    I’ve been looking around for some sort of widget or hack that will let me remove exclude certain categories from certain pages. But I haven’t found anything useful.

    Some help would be appreciated.
    I’m currently using Advanced Category Excluder, but that widget doesn’t have the ability to hide from pages at all

Viewing 4 replies - 1 through 4 (of 4 total)
  • Pages don’t necessarily display posts, but it is possible your theme is designed to show posts in Pages. If that is so, with the help of the Template Hierarchy article, determine what Template is displaying your Pages, then you may need to add some code (e.g. query_posts()) to exclude categories.

    Example

    <?php
    query_posts($query_string . '&cat=-5');
    ?>

    Note the -5 says exclude category id 5.

    Thread Starter wob

    (@wob)

    Thanks for your reply. I realize that I was a little short with the info.

    Anyway, I solved it in another way, using slayers custom widget and the widget that will let you add php straight into widgets.

    the widget that will let you add php straight into widgets

    I’d guess you are talking about Otto’s php code widget.

    Thanks for the feedback–will mark this resolved.

    MichaelH. I’m trying to restrict my posts page from showing category 5 posts. Where do I place the code you mentioned above in the page template I made for this particular page?

    Your help is much appreciated.

    <?php
    query_posts($query_string . '&cat=-5');
    >

    My code:

    <?php
    /*
    Template Name: press
    */
    ?>
    
    <?php
    /**
     * @package WordPress
     * @subpackage Default_Theme
     */
    
    get_header(); ?>
    
    	<div id="content" class="narrowcolumn" role="main">
    
    		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    		<div class="post" id="post-<?php the_ID(); ?>">
    			<div class="entry">
    				<?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
    
    				<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
    
    			</div>
    		</div>
    		<?php endwhile; endif; ?>
    	<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
    	</div>
    
    <?php include ('sidebar1.php'); ?>
    
    <?php get_footer(); ?>

    Thanks
    Tim

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Wants to exclude certain categories from certain pages’ is closed to new replies.