In this article I share sample code of a Page Template which adds a new section below the existing content. The new section displays two loops:
- three entries from
portfolio
CPT - six regular posts tagged
project
Create a file named page-slug.php where slug is your static Page’s slug. In this example, the Page title is “Portfolio and Projects” and its slug is “portfolio-and-projects”. Hence the template is named page-portfolio-and-projects.php inside the child theme directory.
Here’s the PHP code for the above file:
add_action( 'genesis_loop', 'sk_do_loop' );
/**
* Outputs a custom loop
*
* @global mixed $paged current page number if paginated
* @return void
*/
function sk_do_loop() {
// Loop 1
$args1 = (array(
'post_type' => 'portfolio',
'posts_per_page' => 3,
'no_found_rows' => true
));
echo '<h2 class="loop-title">Portfolio</h2>';
genesis_custom_loop( $args1 );
// Loop 2
$args2 = (array(
'tag' => 'project',
'posts_per_page' => 6,
'no_found_rows' => true
));
echo '<h2 class="loop-title">Projects</h2>';
genesis_custom_loop( $args2 );
}
genesis();