• Resolved navets-stevan

    (@navets-stevan)


    Hi , there is many people who have the same problem with me.. But i just can’t understand the solution. Because I’m just new to wordpress and coding..

    Anyway , this is my wordpress loop :

    [mod: added backticks]

    <ul>
      <!-- wp query starts -->
      <?php $the_query = new wp_query('category=offerings posts_per_page=10'); ?>
    
      <?php if ($the_query->have_posts() ) : while ($the_query->have_posts() ) : $the_query->the_post(); ?> 
    
    <li><a>"><?php the_title();?></a></li>
    <li>
      <?php endwhile; else: ?>
      <?php _e('Sorry, no posts matched your criteria.'); ?>
      <?php endif; ?>
      <?php wp_reset_query(); ?>
    </li>
    </ul>

    This loop making is creating
    <li> title </li>
    but the thing is it keep generating empty
    <li> </li>
    after one title post , anyone care to point where i did wrong ?

    Thanks, PS sorry for my bad English.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter navets-stevan

    (@navets-stevan)

    Sorry forget to put the code bacticks sorry, now my post looks like glibberish..

    Anyway here’s my code :

    <ul>
      <!-- wp query starts -->
      <?php $the_query = new wp_query('category=offerings&posts_per_page=15'); ?>
      <?php if ($the_query->have_posts() ) : while ($the_query->have_posts() ) : $the_query->the_post(); ?> 
    
      <li><a href="<?php get_permalink(); ?>"><?php the_title();?></a><li>
    
      <?php endwhile; else: ?>
      <?php _e('Sorry, no posts matched your criteria.'); ?>
      <?php endif; ?>
      <?php wp_reset_query(); ?>
    </ul>

    Hope it makes more sense now, Can it keeps generating empty li tags and with closing li tags..

    Thanks, PS sorry for my bad English.

    you have forgotten the / for the closing li tag:

    should read:

    ...title();?></a></li>

    Thread Starter navets-stevan

    (@navets-stevan)

    Thanks a lot .. I didn’t read it properly ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘WordPress loop looping empty div / li ?’ is closed to new replies.