Support » Plugins and Hacks » Display post different after specific number of posts?

  • Resolved Pajje

    (@pajje)


    Is there a way to style/display posts different after a exact number of posts on index page? Lets say i want to style posts differently after post number 9. Only on index page.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Michael

    (@alchymyth)

    Forum Moderator

    either add a counter to the loop, and use a conditonal statement;
    or use the $wp_query->current_post variable with a conditional statement.

    for ‘only on index page’ look into http://codex.wordpress.org/Conditional_Tags

    alchymyth, is it possible to get som example code? I’m struggling, only get it to work for a specific post number, not for (example) post 9 to 9999.

    Michael

    (@alchymyth)

    Forum Moderator

    is it possible to get som example code?

    please

    tis will depend on the level of ‘style/display posts different’ and on your existing code.

    very general example:

    <?php if( $wp_query->current_post < 9 ) : ?>
    show post in one way
    <?php else : ?>
    show posts in a differnt way
    <?php endif; ?>

    this could be as simple just within the post div to set a css class for the two groups of posts, or wrapping the full output section so you can have a total diffrent html and oputput structure.

    needs to be within the loop.

    Thank you alchymyth you are very helpful, that did the trick!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Display post different after specific number of posts?’ is closed to new replies.