Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a portfolio website where my portfolio updates are supposed to go to both my portfolio and blog pages, as well as show thumbnails for the posts on my homepage.

The thumbnails work perfectly; if a post is to go in two categories, the thumbnails show up in both categories.

My trouble is with the blog- posts marked to go in both blog and portfolio categories only show up in my portfolio. Here's what I'm using for the blog:

<div id="blog">
    <?php query_posts('cat=-4'); ?>
    <?php if(have_posts()) : while(have_posts()) : the_post('cat=-3,4'); ?>
    <div class="post-title">
        <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
    </div><!-- end post-title -->
    <div class="post">
        <?php the_content('read more...'); ?>
    </div><!-- end post -->
    <div class="post-meta">
        <p><?php the_date(); ?> | <?php the_tags('tags:', ', ', '<br />'); ?></p>
    </div><!-- end post-meta -->
    <?php endwhile; ?>
    <?php else : ?>
            <p>I'm not sure what you're looking for.</p>
    <?php endif; ?>
</div><!-- end blog -->

Any ideas what could be causing this or how to remedy?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

First thing : you should not use category ids directly. Use slugs instead : it's easier to maintain.

<?php query_posts('category_name=portfolio'); ?>

Second thing : why did you put a query parameter in the_post ? This function does not accept any parameter (see the Codex).

Third thing : the call to query_posts('cat=-4'); will show all posts EXCEPT the one that have the category N°4 (portfolio, if I guess well). This is not want you want, right ?

Want you want is query_posts('category_name=portfolio'); in your portfolio page and query_posts('category_name=blog'); in your blog page.

share|improve this answer
    
That makes perfect sense, thank you. –  user1255049 Oct 20 '12 at 15:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.