• Resolved unboundedexistence

    (@unboundedexistence)


    Hi,

    I’m having one helluva time customizing a single loop, my index.php loop, to post everything but 2 categories. I’ve read everywhere it should be as simple as putting a simple line of code, <?php $posts = query_posts($query_string.'&cat=-7&posts_per_page=5'); ?>, in the case of category “7,” for instance, just before the loop you’re looking to alter. But no deal.

    Plus I’ve tried every variation I could get my hands on, and nothing is working. Am I not doing something? Like specifying something in the admin area, say? Because I’ve been at this all day, and had various loops do everything, but what I want. Which is to exclude 2 categories, from listing on my front page.

    Many thanks, in advance,

    Johnny

Viewing 5 replies - 1 through 5 (of 5 total)
  • I think you just need to take out the ‘$posts =’ part:

    <?php query_posts($query_string.'&cat=-7&posts_per_page=5'); ?>

    Thread Starter unboundedexistence

    (@unboundedexistence)

    vtxyzzy, no deal.

    I’ve tried everything, that’s why I asked if it could be something else, in the backend.

    Thanks anyway,

    Johnny

    Thread Starter unboundedexistence

    (@unboundedexistence)

    Me oh my, vtxyzzy,

    In my attempts to resolve another, unrelated issue, last week, I ditched an old install for a fresh new one. And upon database import for the new install, some of my ID’s were switched, rendering my theme useless. A mighty good reason not to rename the “uncategorized” category, eh? Anyway, that explains everything, and embarrasses me to no end. Live and learn, I guess. I won’t be making that mistake anytime soon, again.

    Thank for your help,

    Johnny

    Do you get the posts_per_page=5, but not the category exclusion, or is it all ignored? If it is all, are you sure that the code is even getting executed?

    Perhaps you could post 5-10 lines before and after the query_posts, or copy the entire index.php to wordpress.pastebin.ca and post a link here so others can look at it.

    Thread Starter unboundedexistence

    (@unboundedexistence)

    I’m sorry, vtxyzzy,

    I should have stated, outright, I got it figured out. I’m good to go.

    Thanks,

    Johnny

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Custom loop not working’ is closed to new replies.