• Hi, so I got code that displays all post in current category right here:

    <ul>
    <?php foreach((get_the_category($post->ID)) as $category) { ?>
    
    <?php $catVal = $category->cat_ID; }
       $IDOutsideLoop = $post->ID;
       global $post;
    $myposts = get_posts('category='.$catVal.'&numberposts=999&order=ASC');
       foreach ($myposts as $post) { ?>
         <li<?php if($IDOutsideLoop == $post->ID) { echo " class=\"current\""; } ?>>
         <a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
    <?php }; ?>
    </ul>

    All I need is to echo some html code only after 3 item from the loop. I`m not a php guy, so please If You be so kind and give me ready and workind code I will be delighted. Thank You.

    Rafał

Viewing 5 replies - 1 through 5 (of 5 total)
  • Try this

    <ul>
    <?php foreach((get_the_category($post->ID)) as $category) { ?>
    
    <?php $catVal = $category->cat_ID; }
       $IDOutsideLoop = $post->ID;
       $i=0;
       global $post;
    $myposts = get_posts('category='.$catVal.'&numberposts=999&order=ASC');
       foreach ($myposts as $post) { ?>
         <li<?php if($IDOutsideLoop == $post->ID) { echo " class=\"current\""; } ?>>
         <a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
    <?php $i++; if($i==3) { echo 'your html code'; } }; ?>
    </ul>
    Thread Starter zecke

    (@zecke)

    And I got another problem with the same code and I can`t figure it out.

    I need to change this code to show only 3 first items from the loop. Then after those 3 items I need something like “read more” link and after clicking that I want to get rest of the loop.

    Of course even wihtout clicking “read more” all items from the loop suppose to be visible in source code for bots to indexing.

    If You know how to help me, do not hesistate 🙂
    Thanks
    btw. I`m in love with WordPress

    Please post a new topic about this.

    That won’t happen in this case.

    Thread Starter zecke

    (@zecke)

    Ok. Thanks. I posted it as a new one

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Put some html code after third item in the loop’ is closed to new replies.