WordPress.org

Ready to get started?Download WordPress

Forums

Displaying news (or what ever) in a second sidebar? (2 posts)

  1. hilj
    Member
    Posted 7 years ago #

    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.

  2. hilj
    Member
    Posted 7 years ago #

    I read the http://codex.wordpress.org/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

Topic Closed

This topic has been closed to new replies.

About this Topic