opinion on custom index.php

I need something that displays headlines (large and small) and then goes on to show the rest of the posts without repeating the posts displayed in the headline. It all seems to work except for the total count of posts once on the loop. My question is whether I am doing it well or whether there is a "better" way of making this...

  • wally9
    <?php get_template_part('templates/page', 'header'); ?>
    
    <div class="leftsidebar"><?php dynamic_sidebar('sidebar-left'); ?></div>
    <div class="top-ad"></div>
    <div class="middle">
    <?php if(is_front_page() ) { ?>
    <!--headline large-->
    <?php $ids = array(); query_posts('category_name=headline&showposts=1'); ?>
    <?php while (have_posts()) : the_post(); ?>
     <a href="<?php the_permalink(); ?>">
              <?php the_title(); ?>
              </a><?php $ids[]= $post->ID;
             endwhile; ?>
    <?php wp_reset_query();?>
    <!--headline small-->
    <?php $ids = array(); query_posts('category_name=headline2&showposts=4'); ?>
    <?php while (have_posts()) : the_post(); ?>
            <a href="<?php the_permalink(); ?>">
              <?php the_title(); ?>
              </a>
            <?php $ids[]= $post->ID;
             endwhile; ?>
    <?php wp_reset_query();?>
    <!--rest of the posts excluding the headlines-->
    <?php if (have_posts()) : ?>
      <div class="main-wrap">
    <?php while (have_posts()) : the_post();
    if (!in_array($post->ID, $ids)) { ?>
      <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
        <header>
          <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
          <?php get_template_part('templates/entry-meta'); ?>
        </header>
        <div class="entry-summary">
          <?php the_excerpt(); ?>
        </div>
        <footer>
          <?php the_tags('<ul class="entry-tags"><li>','</li><li>','</li></ul>'); ?>
        </footer>
      </article>
    <?php }
    endwhile; ?>
      </div>
    <?php if ($wp_query->max_num_pages > 1) : ?>
      <nav class="post-nav">
        <ul class="pager">
          <?php if (get_next_posts_link()) : ?>
            <li class="previous"><?php next_posts_link(__('View more articles', 'roots')); ?></li>
          <?php else: ?>
            <li class="previous disabled"><a><?php _e('View more articles', 'roots'); ?></a></li>
          <?php endif; ?>
    
        </ul>
      </nav>
    <?php endif; ?>
    <?php endif; ?>
    <?php } else { ?>
    <!--NOT HOMEPAGE-->
    <?php if (have_posts()) : ?>
      <?php get_template_part('templates/content', get_post_format()); ?>
    <?php endif; ?>
    <?php } ?>
    </div>
  • wally9

    With the help of some staff members I managed to make what I want using wp query like this:

    <!--headline large-->
    
    <?php $idsl = array(); $query = new WP_Query('category_name=headline&posts_per_page=1'); ?>
    
    <?php  while ( $query->have_posts() ) : $query->the_post(); ?>
    
    <div class="headlinelarge">
    <div class="hlcategories"><?php exclude_post_categories('2075,2076',', '); ?></div>
    <div class="hltitle"><h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2></div>
    <div class="hltime">
    <?php the_time('M j, Y') ?> <?php echo __('by', 'roots'); ?> <a href="<?php echo get_author_posts_url(get_the_author_meta('ID')); ?>" rel="author" class="fn"><?php echo get_the_author(); ?></a></div>
    
    <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><img class="small-headline" src="<?php echo catch_first_image() ?>"></a>
    
    <div id="hltext"><?php the_excerpt(); ?></div>	
    
    	</div>
    <?php $idsl[]= $post->ID; endwhile; ?>
    <?php wp_reset_query();?>

    and changing it to create diferent headlines on my frontpage

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.