Display Custom Post Type.

PHP Code Snippets/Functions

This snippet is a loop used for displaying custom posts. Replace variables/IDs/names/attributes as needed.

<?php 
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$loopb = new WP_Query( array( 'post_type' => 'post', 'posts_per_page' => 3, 'paged' => $paged, 'orderby' => 'post_date', 'order' => 'DESC' ) );
$ctr = 0;
while ( $loopb->have_posts() ) : $loopb->the_post();
$post_ID = get_the_id();
$content = get_the_content();
$thumb_image_arr = wp_get_attachment_image_src(get_post_thumbnail_id(),'full');
$thumb_image = $thumb_image_arr[0];
?>
<div class="home-press-item">
<a href="<?php the_permalink(); ?>">
<div class="home-press-img">
<img src="<?php echo $thumb_image; ?>" />
</div>
<span class="home-press-date"><?php echo get_the_date('F d, Y'); ?></span>
<h4 class="home-press-title"><?php the_title(); ?></h4>
</a>
</div>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>

Leave a Reply

Your email address will not be published. Required fields are marked *