Created
March 17, 2015 12:17
-
-
Save kaskajp/91cf4bacfa601efae5b4 to your computer and use it in GitHub Desktop.
Custom Post Type Loop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; | |
query_posts(array( | |
'post_type' => 'myposttype', | |
'posts_per_page' => 10, | |
'paged' => $paged) | |
); | |
?> | |
<?php if ( have_posts() ) : ?> | |
<?php while ( have_posts() ) : the_post(); ?> | |
<?php $thumb = get_the_post_thumbnail($post->ID, 'md4'); ?> | |
<?php if($thumb): ?> | |
<a href="<?php the_permalink(); ?>"><?php echo $thumb; ?></a> | |
<?php else: ?> | |
<a href="<?php the_permalink(); ?>"><img src="http://placehold.it/287x196" alt="" /></a> | |
<?php endif; ?> | |
<h1><?php the_title(); ?></h1> | |
<?php endwhile; ?> | |
<?php | |
// Add pagination here | |
// E.g. | |
// if(function_exists('wp_paginate')) { | |
// wp_paginate(); | |
// } | |
?> | |
<?php else: ?> | |
<p>No posts found.</p> | |
<?php endif; ?> | |
<?php wp_reset_query(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment