I'd published this previously Stack Overflow, but could not get an optimistic result. I figured I ought to do that again.

<?php require_once 'news/wp-config.php';
$howMany = 0;
$query ="SELECT `ID`, `post_title`,'post_category', `guid`,SUBSTRING_INDEX(`post_content`, ' ', 100) AS `post_excerpt` FROM $wpdb->posts WHERE `post_status`= \"publish\" AND `post_type` = \"post\" AND post_category != \"1\" ";
$posts = $wpdb->get_results($query);
$posts = array_reverse($posts);
foreach($posts as $post)
        $link = $post->guid;
        echo "<li><a target='_blank' href='$link'>$post->post_title</a></li>";


I would like the above mentioned code to not display posts from Category 1. I believe I've done everything right, but nonetheless I can not obtain the result which i want.

Yet another factor is that if I even clearly request the query to show the posts from category three or four, it does not happen. It eventually ends up exhibiting posts all groups.

You need to use the query_posts() function. Otherwise, a minimum of eliminate that $howMany variable and rather append "LIMIT 10" for your sql query.

Here's a good example of obtaining a category prepared for that loop:

     // Borrowed heavily from link above...
     $categoryvariable=1; // assign the variable as current category
     $numposts = 10;
     // Set up the query
     $query= 'cat=' . $categoryvariable. '&orderby=date&order=ASC&showposts='.$numposts;      
     query_posts($query); // run the query

//The Loop
if ( have_posts() ) : while ( have_posts() ) : the_post();
     // Do all your echo stuff here
endwhile; else:


//Reset Query


I'd second while using wordpress functions.

Here is a great resource http://codex.wordpress.org/Function_Reference/query_posts

The right syntax could be query_posts('category__not_in=1')

I believe you stated you did not need it in category 1.