WordPress.org

Forums

[resolved] Loop Cycle (4 posts)

  1. Luigino
    Member
    Posted 5 years ago #

    hello everyone!!!

    I have this homemade loop cycle:

    <div id="content">
    <?php query_posts("category__not_in=24"); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <?php if (in_category("24")) continue; ?>
    <div class="post" id="post-<?php the_ID(); ?>">
    <div class="post-head">
    <div class="post-date"><span class="post-month"><?php the_time('M') ?></span> <span class="post-day"><?php the_time('d') ?></span></div>
    <div class="post-blocktitle">
    <h2 class="post-title">" class="post-title" rel="bookmark"><?php the_title(); ?></h2>
    <span class="post-author">Inserito da: <?php the_author(); ?> in <?php foreach((get_the_category()) as $category) { echo $category->cat_name . ' ';} ?> il <?php the_time('j F Y') ?></span>
    </div><!--[post-blocktitle]-->
    </div>
    <div class="post-contents">
    <div class="post-content"><?php the_content('Continue...»'); ?></div>
    </div><!--[post contents]-->
    </div><!-- [post] -->
    <?php endwhile; ?>
    <div class="navigation">
    <span class="previous-entries"><?php next_posts_link('Previous Entries...') ?></span><span class="next-entries"><?php previous_posts_link('Next Entries...') ?></span>
    </div>
    <?php else : ?>
    <p class="center">I'm sorry, there are no posts in this page.</p>
    <?php endif; ?>
    </div><!--[content]-->

    where with category 24 there are posts that I use for sticky boxes... here indeed I have no posts in other categories so I should get "I'm sorry, there are no posts in this page." but I get "Previous entries"...that's weird to me because that "if (have_posts())" should return false and show the message "I'm sorry..."

    Any suggest?

    Thanks!!
    Ciao
    Luigi

  2. MichaelH
    Member
    Posted 5 years ago #

    How about:

    $args=array(
       'category__not_in' => array(24),
       'caller_get_posts'=>1
       );
    query_posts($args);
  3. Luigino
    Member
    Posted 5 years ago #

    Yes now it works!!!
    Even it was weird before because I followed an example from codex about using category_not_in=24... at least now it works with this code sample :-)

    Thanks MichaelH :-)

  4. MichaelH
    Member
    Posted 5 years ago #

    You're welcome--if you could point out that Codex example I'll fix it.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.