Posted By

oneupdzn on 05/05/13


Tagged

wordpress loop


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

zemonte
b83s


Wordpress basic loop


 / Published in: PHP
 

Basic wordpress loop.

  1. <!-- if there are posts -->
  2.  
  3. <?php if (have_posts()) : ?>
  4.  
  5. <!-- while there are posts -->
  6.  
  7. <?php while (have_posts()) : the_post(); ?>
  8.  
  9. <!-- the posts -->
  10.  
  11. <div class="post" id="post-<?php the_ID(); ?>">
  12.  
  13. <h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
  14.  
  15. <!-- Custom field of "PostThumb" -->
  16.  
  17. <?php echo get_post_meta($post->ID, 'PostThumb',true); ?>
  18.  
  19. <!-- post meta -->
  20.  
  21. <p class="meta">
  22. <span>Posted on</span><time datetime="<?php the_time('c');?>"><?php the_time();?></time> <span>by</span> <?php the_author(); ?>
  23. </p>
  24.  
  25. <!-- get content / show "Read Full Article" link at break -->
  26.  
  27. <?php the_content('Read Full Article'); ?>
  28.  
  29. <!-- get tags -->
  30.  
  31. <p><?php the_tags('Tags: ', ', ', '<br />'); ?>
  32.  
  33. <!-- get category -->
  34.  
  35. Posted in <?php the_category(', '); ?>
  36.  
  37. <!-- get comments -->
  38.  
  39. <?php comments_popup_link('No Comments;','1 Comment', '% Comments'); ?></p>
  40. </div>
  41.  
  42. <!-- end loop -->
  43.  
  44. <?php endwhile; ?>
  45.  
  46. <!-- show pagination links -->
  47.  
  48. <?php next_posts_link('Older Entries'); ?>
  49. <?php previous_posts_link('Newer Entries'); ?>
  50.  
  51. <1-- if no posts -->
  52.  
  53. <?php else : ?>
  54.  
  55. <h2>Nothing Found</h2>
  56.  
  57. <?php endif; ?>

Report this snippet  

You need to login to post a comment.