Display a list of Custom Post Types as a blog


/ Published in: PHP
Save to your folder(s)

This will fetch the custom post types, displayed as a list with their respective permalinks.


Copy this code and paste it in your HTML
  1. <?php query_posts( 'post_type=work&posts_per_page=1'.'&paged='.$paged); ?>
  2. <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
  3.  
  4. <li class="illustrations">
  5.  
  6. <?php the_title('<h4 class="nice-titles"><a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '" rel="bookmark">', '</a></h4>' ); ?>
  7. <?php
  8. if(has_post_thumbnail()) {
  9. the_post_thumbnail();
  10. } else {
  11. echo '<img src="'.get_bloginfo("template_url").'/images/default_img.jpg" />';
  12. }
  13. ?>
  14. <?php the_excerpt(); ?>
  15. <a href="<?php the_permalink(); ?>">More...</a>
  16.  
  17. </li>
  18. <!-- /item -->
  19. <?php endwhile; ?>
  20. <div class="navigation">
  21. <div class="alignleft"><?php next_posts_link('&laquo; Previous Entries') ?></div>
  22. <div class="alignright"><?php previous_posts_link('Next Entries &raquo;') ?></div>
  23. </div>
  24. <?php else: ?>
  25. <p><?php _e('Not Found','ivorpad'); ?></p>
  26. <?php endif; ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.