Created
July 20, 2012 15:02
-
-
Save mattboon/3151186 to your computer and use it in GitHub Desktop.
WordPress - Example index page for custom post type
This file contains 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 | |
/* | |
Template Name: You post type | |
*/ | |
?> | |
<?php get_header(); ?> | |
<?php get_template_part('inc/page-title'); ?> | |
<div class="main content" role="main"> | |
<?php | |
// http://codex.wordpress.org/Function_Reference/query_posts | |
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; | |
$args = array( | |
'post_type'=> 'post_type_name', | |
'paged' => $paged | |
); | |
} | |
// get your posts | |
query_posts( $args ); | |
if (have_posts()) : ?> | |
<!-- stuff before posts --> | |
<?php while (have_posts()) : the_post(); ?> | |
<?php get_template_part('inc/loop'); ?> | |
<?php endwhile; ?> | |
<?php get_template_part('inc/pagination'); ?> | |
<?php else : ?> | |
<p class="empty"><strong>No posts yet</strong></p> | |
<?php | |
endif; | |
wp_reset_query(); | |
?> | |
</div> | |
<?php get_sidebar(); ?> | |
<?php get_footer(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment