Morning all,
I’m having some issues with excluding my custom post-type ‘events’ from my index.php loop for my Blog page.
I simply want to display the posts from my actual Blog, which I assume come under the post-type ‘post’, but when I try to display the ‘post’ type it also shows my ‘events’ post-type.
Here’s my loop code:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="individualPost">
<h1 class="bottomBorder"><a href="https://wordpress.stackexchange.com/questions/30077/<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h1>
<ul class="blogMeta">
<li><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?></li>
<li>Posted in <?php the_category(', '); ?></li>
</ul>
<?php if (has_post_thumbnail( $post->ID )): ?>
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); ?>
<a href="https://wordpress.stackexchange.com/questions/30077/<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><img src="<?php bloginfo('template_directory'); ?>/thumbs.php?src=<?php echo $image[0]; ?>&w=615&h=200&zc=1" alt="<?php the_title(); ?>" /></a>
<?php endif; ?>
<!-- Display the Post's Content in a div box. -->
<?php the_excerpt(); ?>
</div>
<?php endwhile;?>
<?php else : ?>
<div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
<h1>Not Found</h1>
</div>
<?php endif; ?>
I’ve also tried this, with no luck:
<?php $loop = new WP_Query( array( 'post_type' => 'post', 'posts_per_page' => 5 ) ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="individualPost">
<h1 class="bottomBorder"><a href="https://wordpress.stackexchange.com/questions/30077/<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h1>
<ul class="blogMeta">
<li><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?></li>
<li>Posted in <?php the_category(', '); ?></li>
</ul>
<?php if (has_post_thumbnail( $post->ID )): ?>
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); ?>
<a href="https://wordpress.stackexchange.com/questions/30077/<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><img src="<?php bloginfo('template_directory'); ?>/thumbs.php?src=<?php echo $image[0]; ?>&w=615&h=200&zc=1" alt="<?php the_title(); ?>" /></a>
<?php endif; ?>
<!-- Display the Post's Content in a div box. -->
<?php the_excerpt(); ?>
</div>
<?php endwhile;?>
Thanks