treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Wordpressify this!

  • Hey all,

    after fiddling around with my base HTML i decided to move on and mount it to WP. This is my HTML skeleton.

    In my first attempt I could not find out how to separate the fullscreen blogpost from the archive properly (had to set the shown posts per page to one but then there was only one image in the archive, too).

    Now my question is: what's the best way to make my template a theme? My main problem is, that a full post and the archive is basically on one page. How should I compose my index.php?

    Any ideas?

  • You could just make a custom page with two loops.

    For the fullscreen one this should be good:

    <?php $my_query = new WP_Query('showposts=1');
        while ($my_query->have_posts()) : $my_query->the_post();
      $do_not_duplicate = $post->ID; ?>
    Stuff goes here.
    <?php endwhile; ?>
    

    For the archive you'll simply use the regular loop code with a small change. We don't want the archive to show the fullscreen one do we:

    <?php if (have_posts()) : while (have_posts()) : the_post();
      if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>
    Stuff yet again.
    <?php endwhile; endif; ?>