title: PHP code to display all posts based on category
body: <p>I wish to insert a line of code inside my wordpress main page index.php which would display all posts except for posts that fall in 'Diary' category.</p>
  
  <p>the original line of code is as follows</p>
  
  <pre><code>&lt;?php if(have_posts()) : ?&gt;&lt;?php while(have_posts()) : the_post(); ?&gt;
      &lt;div &lt;?php post_class(); ?&gt;&gt;
      &lt;span class="postlabel"&gt;&lt;a href="&lt;?php the_permalink() ?&gt;"&gt;&lt;span&gt;&lt;?php the_time('d'); ?&gt;&lt;/span&gt;&lt;?php the_time('M'); ?&gt;&lt;/a&gt;&lt;/span&gt;
          &lt;h2 class="post-title"&gt;&lt;a href="&lt;?php the_permalink() ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h2&gt; 
              &lt;p class="info"&gt;
                  &lt;span class="catinfo"&gt;&lt;?php _e('Filed in ', 'Mflat');?&gt;&lt;?php the_category(' | ') ?&gt;&lt;/span&gt;
                  &lt;span class="cmtinfo"&gt;&lt;?php comments_popup_link( __( 'Leave a comment', 'Mflat' ), __( '1 Comment', 'Mflat' ), __( '% Comments', 'Mflat' ) ); ?&gt;&lt;?php edit_post_link(' Edit', ' &amp;#124; ', ''); ?&gt;&lt;/span&gt;
              &lt;/p&gt;
          &lt;div class="entry"&gt;
              &lt;?php $Mflat_options = get_option('Mflat_theme_options'); ?&gt;
              &lt;?php if ( $Mflat_options['home_excerpt_check']== 1 ) { the_excerpt(__('&amp;raquo; Read more','Mflat')); } else {the_content(__('Continue Reading','Mflat'));} ?&gt;
           &lt;/div&gt;
          &lt;?php wp_link_pages(array('before' =&gt; '&lt;p&gt;&lt;strong&gt;Pages:&lt;/strong&gt; ', 'after' =&gt; '&lt;/p&gt;', 'next_or_number' =&gt; 'number')); ?&gt;
              &lt;p class="infobottom"&gt;
                  &lt;?php if(function_exists('the_views')): ?&gt;&lt;span class="count"&gt;&lt;?php the_views(); ?&gt;&lt;/span&gt;&lt;?php endif; ?&gt;
                  &lt;?php if (has_tag()): ?&gt;&lt;span class="tags"&gt;&lt;?php the_tags(' '); ?&gt;&lt;/span&gt;&lt;?php endif; ?&gt;
                  &lt;/p&gt;
      &lt;/div&gt;
          &lt;?php endwhile; ?&gt;
      &lt;div class="flip"&gt;
          &lt;div class="prevpost"&gt;&lt;?php next_posts_link(__('Older Entries', 'Mflat')) ?&gt;&lt;/div&gt;
          &lt;div class="nextpost"&gt;&lt;?php previous_posts_link(__('Newer Entries', 'Mflat')) ?&gt;&lt;/div&gt;
      &lt;/div&gt;
  &lt;?php else : ?&gt;
  &lt;div id="main"&gt;
   &lt;h2&gt;&lt;?php _e('Not Found', 'Mflat'); ?&gt;&lt;/h2&gt;
  &lt;/div&gt;
      &lt;?php endif; ?&gt;
  </code></pre>
  
  <p>I tried the following codes but to no avail</p>
  
  <pre><code>&lt;?php if(have_posts()) : ?&gt;&lt;?php while(have_posts()){
      &lt;if(!in_category('Diary')){
          : the_post(); 
          }
      }?&gt;
  </code></pre>
  
  <p>Is there any better way i can get this done?
  I am new to PHP and though i know the logic of what has to be done, i cant quite generate the code to make this work. I think boolean would be a little too much work and found a similar (http://stackoverflow.com/questions/13587958/display-recent-posts-based-on-their-category-in-wordpress) thread on stark overflow but it doesnt quite suit my needs. </p>
  
  <p>Every contribution is dearly appreciated. Thanks</p>