0
votes

I trying to adapt a static page to WordPress. In front page, after some branding i need to show latests posts in 4 different divs with a "read more" link. The static page is this: http://cmshop.site90.com/

How can i achieve this? Can you please help me. i m using a template which looks like this:

    <?php /*
    Template Name: No sidebar page
*/ ?>

<?php get_header(); ?>

    <div id="add">
<h1>Ravinto<br>
  &Terveys</h1>
  <img src ="http://akselgumus.com/wordpress1/wp-content/uploads/2014/11/struc.jpg">
</div> <!-- #add -->

<div id="sum"></div>
<div id="sum"></div>
<div id="sum"></div>
<div id="sum"></div>

<?php get_footer(); ?>

Latest posts should go into

1
I'll point out you can't have 4x <div> elements with the same id (sum). Ids should be unique per page, so either give them different ids or else use a class instead - Dre

1 Answers

0
votes

if i understand your question you just need include counter and class in your wp_query, becouse easyer make that "format" what you want.. i'll post here one sample:

<?php
// The Query
  $query = new WP_Query(array( 'post_type' => 'post', 'cat' => 1   ));
  query_posts( $args );
  $i= 1;
// The Loop
  while ( $query->have_posts() ) : $query->the_post(); ?>
    <div class="sum sum<?php echo $i; ?>">
      <a href="<?php echo the_permalink(); ?>"><?php the_title(); ?></a>
      <p> <?php the_excerpt(); ?> </p>
    </div> 
  <?php $i++;   
  endwhile;
// Reset Query
  wp_reset_query();
?>

Then you will have

<div class="sum sum1">post content</div> 
<div class="sum sum2">post content</div>
<div class="sum sum3">post content</div>
<div class="sum sum4">post content</div>

Good luck!! :)