Tuesday, August 23, 2016

Wordpress Custom Post Loop Codex

<?php
/**
 * Template Name: Portfolio
 * The template for displaying portfolio posts.
 *
 */

get_header(); ?>

<div id="primary" class="content-area col-md-9">
<main id="main" class="site-main" role="main">
<?php

            $args = array( 'post_type' => 'portfolio', 'posts_per_page' => 9 );
            $loop = new WP_Query( $args );
            while ( $loop->have_posts() ) : $loop->the_post(); ?>

            <?php get_template_part( 'content', 'page' ); ?>

<?php
// If comments are open or we have at least one comment, load up the comment template
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
?>

<?php endwhile; // end of the loop. ?>

</main><!-- #main -->
</div><!-- #primary -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>

No comments:

Post a Comment