0

i having trouble while i added query to loop.

please have a look whats the problem.

here is the link

 <div class="fl" id="main_article">
 <?php $count = 1;
 $the_query = new WP_Query( 'category_name=headline&orderby=post_date&order=desc' );

    if ( $the_query->have_posts() ) : while (have_posts()) : $the_query->the_post();       if($count == 1) : ?>

 <a href="<?php the_permalink() ?>" rel="bookmark" title=""><?php the_title(); ?></a>
 <?php dynamic_excerpt(400); ?>
 <?php else : ?>

 <div class="post">
 <a href="<?php the_permalink() ?>" rel="bookmark" title=""><?php the_title(); ?></a>
 <?php dynamic_excerpt(400); ?>  </div>

 <?php if ($count== 2 || $count == 4 ){ ?>  

 <?php dynamic_sidebar('index-insert') ?>
 <?php } ?>
 <?php $count = $count + 0; ?>
    <?php endif; ?>
<?php $count++; ?> 
<?php endwhile; ?> </div>

1 Answer 1

1

no idea what the problems actually are, but from looking at the code, I woud suggest:

a: the while (have_posts()) : should be while ($the_query->have_posts()) :

b: you would need to increment the counter: <?php $count = $count + 1; ?>

c: the endif; of the loop might be missing after the endwhile; - at least it is not shown in the posted code section.

2
  • thanks for your reply !! done here is the <?php $count = 1; $the_query = new WP_Query('category_name=headline&orderby=post_date&order=desc'); if ($the_query->have_posts()) :?> <?php while ($the_query->have_posts()) : $the_query->the_post(); if($count == 1) : ?> Commented Jul 19, 2012 at 10:51
  • what is or was the actual problem with the code?
    – Michael
    Commented Jul 19, 2012 at 12:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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