Support » Plugins » Hacks » Insert stuff on categories page without it looping with post list

  • Resolved celloblue

    (@celloblue)


    Hi, I would like to insert an image or other item between the posts listed on categories page, with the image appearing just once after the first post listed on the page. This is in contrary to reappearing in every instance of post loops. Thanks in advance for any help or suggestions!

Viewing 5 replies - 1 through 5 (of 5 total)
  • insert something like this before the endwhile of the loop on category.php:

    <?php if( $wp_query->current_post == 0 ) { ?>
    <!--your html image code-->
    <?php } ?>

    That was very quick. Thank you! Another question, so if I want the item to loop twice or more but in a specific number of times, what do I do?
    Thank you so much!

    if I want the item to loop twice or more but in a specific number of times

    the current_post counter starts with 0 zero for the first post in the loop.

    example 1:
    after each of the first three posts:

    <?php if( $wp_query->current_post <= 2 ) { ?>

    example 2:
    after post 1, post 4 and post 6:

    <?php if( in_array( $wp_query->current_post, array( 0, 3, 5 ) ) ) { ?>

    http://uk3.php.net/in_array

    Thanks!

    Just marking this as resolved.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Insert stuff on categories page without it looping with post list’ is closed to new replies.