Get Posts from Custom Post Type


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

Get posts from a Custom Post Type


Copy this code and paste it in your HTML
  1. <?php $loop = new WP_Query( array( 'post_type' => 'vehicles', 'posts_per_page' => 30 ) ); ?>
  2.  
  3. <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
  4.  
  5. <div class="vehicle_repeater"> <a href="<?php echo get_permalink(); ?>"><?php echo get_the_post_thumbnail($page->ID, ''); ?></a>
  6. <div class="vehicle_text_box">
  7. <?php the_title( '<h4><a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '" rel="bookmark">', '</a></h4>' ); ?>
  8. <p class="vehicle_small_text">
  9. <?php
  10. $myExcerpt = get_the_excerpt();
  11. if ($myExcerpt != '') {
  12. // Some string manipulation performed
  13. }
  14. echo $myExcerpt; // Outputs the processed value to the page
  15. ?>
  16. </p>
  17. </div>
  18. </div>
  19. <?php endwhile; ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.