• I’d like to display news in a second sidebar. News would most obviously be handy to do using Posts, rather than Pages. But when I write a post it appears on the front page, of course. So how can I configure it so that the “news posts” I’m writing appear only in the second sidebar?

    Thank you.

Viewing 1 replies (of 1 total)
  • Thread Starter hilj

    (@hilj)

    I read the https://codex.www.ads-software.com/The_Loop file. It says that “If the post is in the category we want to exclude, we simply pass to the next post.”

    <?php if (in_category('3')) continue; ?>

    So I’m trying to exclude the Posts in the “NEWS” gategory from displaying in the main “entry” div, and to display in the second sidebar.

    The_Loop file also says that “Get the last 10 posts in the special_cat category.” Like this:

    <?php query_posts('category_name=special_cat&showposts=10'); ?>

    I try to put that in my second sidebar, but I cant do any of this.

    My index.php looks like this.

    <div id="content" class="narrowcolumn">
    
    	<?php if (have_posts()) : ?>
    
    		<?php while (have_posts()) : the_post(); ?>
    		<?php if (in_category('NEWS')) continue; ?>
    			<div class="post">
    				<h3 id="post-<?php the_ID(); ?>"><?php the_title(); ?> <cat><?php the_category(', ') ?></cat></h3>
    				<div style='border-bottom:1px #aaa solid;width:100%;'>
    
    				<div class="entry">
    					<?php the_content('More &darr;'); ?>
    				</div>
    
    			</div>
    
    		<?php endwhile; ?>

    So how to include and exclude categories?

    Thanks

Viewing 1 replies (of 1 total)
  • The topic ‘Displaying news (or what ever) in a second sidebar?’ is closed to new replies.