• I am new to wordpress but not so with css, html, php etc.

    I am attempting to use the wp_get_recent_posts() function in order to loop over the posts and echo them out with customized class attributes.

    Now I am certain this is not the most efficient method to use and am seeking information on the best methods for applying specific styles. Currently some, not all of my div class attributes are being applied.

    Here is my example. Any experienced theme developers know of a better way?

    <?php
     $recent_posts = wp_get_recent_posts(5);
     foreach($recent_posts as $post){
      echo '<div class="left-article">';
      echo '<a href="#"><img class="blog-img" src="images/aaalogo-min.png" alt="blogimg1" /></a>';
      echo '<div class="title"><a href="'.get_permalink($post['ID']).'">'.$post['post_title'].'</a></div>';
      echo '<div class="infobubble">Posted on '.$post['post_date'].'</div>'; // this class is not being applied
      echo '<div class="commentbubble"><a href="'.get_permalink($post['ID']).'#comments">'.$post['comment_count'].'</a></div>'; // this class is not being applied
      echo '</div>';
      echo '<div class ="content">';
      echo '<p class="blogarticle">'.$post['post_content'].'</p>';
      echo '<a href="'.get_permalink($post['ID']).'">Continue reading</a>'; // this class is not being applied
      echo '</div>';
     }
    ?>

The topic ‘Styling templates help?’ is closed to new replies.