I have a Wordpress custom page template created listing all of my blog posts. What I am trying to do is display a blog page, which lists all posts with 10 per page, with navigation, and exclude category 12, category 20, and category 50 from the list.
For some reason, I cannot get it to exclude these categories. I have even tried to exclude just one category and it still won't.
I am including the code that I am using for this page. If there is a better way to do this, I am open to it. What I am doing is showing the page title, the post title, an excerpt, and a read more link.
Thanks for your help.
Code:
PHP Code:
<?php /*Template Name:Blog*/ ?>
<?php get_header(); ?>
<!--HEADER END HERE-->
<!--CONTENT STARTS HERE-->
<div class="modern-content-blog">
<div class="left">
<h2> <?php the_title(); ?> </h2>
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts('cat=-12,');
$args = array( 'post_type' => 'post', 'posts_per_page' => 10, 'paged' => $paged );
$wp_query = new WP_Query($args);
while ( have_posts() ) : the_post(); ?>
<h2 class="post-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
Posted by: <?php the_author() ?> on <?php the_time('F jS, Y'); ?>
<?php the_excerpt(); ?>
<a href="<?php the_permalink(); ?>" title="Read the rest of <?php the_title(); ?>" class="button">Read the rest of this entry »</a>
<div class="hr"></div>
<?php endwhile; ?>
<!-- PAGINATION STARTS HERE -->
<div class="button"><?php next_posts_link( '<< Older posts' ); ?></div> <div class="button"><?php previous_posts_link( 'Newer posts >>' ); ?></div>
</div>
<div class="right">
<ul>
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('social-sidebar') || !dynamic_sidebar('blog-sidebar') ) { ?>
<?php } ?>
</ul>
</div>
</div>
<!--FOOTER START HERE-->
<?php get_footer(); ?>