• Hi Everyone,
    I have done this before with success but seem to be missing something with this code. On the blog page, I want to show all posts except ID 3 and 5.

    Here is the code:

    <?php
global $more;
$more = 0;
$paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; query_posts(“category_name=blog&paged=$paged&posts_per_page=10”);
$count=1;
while(have_posts()): the_post();
$mykey_values = get_post_custom_values(‘image’);
?>

    Thanks for any help!
    
Steve

Viewing 8 replies - 1 through 8 (of 8 total)
  • Have a look at the second example from Query Posts

    HTH

    David

    Thread Starter steve@skgraphicdesign.com

    (@steveskgraphicdesigncom)

    Hi David,

    It makes sense but I having the issue of what actual info and where do I place it.

    I know it will go in with this piece of code.
    query_posts(“category_name=blog&paged=$paged&posts_per_page=10”)

    But that is where I am stumped.

    Any ideas from your end?

    Ok looking at your reply, do you want to exclude posts from a category, or as the title says exclude some categories from say the home page?

    <?php
    $args = array(
    	'cat' => '-1,-2,-3',
    	'posts_per_page' => 10,
    	'paged' => $paged,
    	'order'    => 'DESC'
    );
    query_posts( $args );
    ?>

    This bit is confusing?

    category_name=blog

    HTH

    David

    Thread Starter steve@skgraphicdesign.com

    (@steveskgraphicdesigncom)

    Hi David,

    The two posts I have are located in the January archives

    Here is the link for the site.
    http://pediatricfamilydental.com/temp/?page_id=30

    I want exclude All Aboard and Our Stations from showing on the blog page itself. Is there a way to hide these from showing here?

    These two posts are used on the home page which is fine but becasue they are posts, they show under archives on the blog page.

    Thanks
    Steve

    Thread Starter steve@skgraphicdesign.com

    (@steveskgraphicdesigncom)

    category_name=blog is basically saying to list all posts that fall under the category Blog. The other two items that show have their own category name which makes it confusing of why they would show under archives.

    Thread Starter steve@skgraphicdesign.com

    (@steveskgraphicdesigncom)

    the more I dig into this it appears that the posts only appear as archive posts. Is there a way to hide on the blog page under archives?

    It looks like you have fixed it by changing the post categories?

    If it is resolved, please let us know the solution and mark the topic as resolved.

    Regards

    David

    Thread Starter steve@skgraphicdesign.com

    (@steveskgraphicdesigncom)

    No it is not fixed, I think I just figured out why it is not changing in my template files. It shows all posts associated with the category name “blog”. I think I need some type of “if statement”. If home then show the two posts otherwise if blog page do not show.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Exclude category posts’ is closed to new replies.