Skip to content

Instantly share code, notes, and snippets.

@wpperform
Created December 30, 2012 04:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpperform/4410990 to your computer and use it in GitHub Desktop.
Save wpperform/4410990 to your computer and use it in GitHub Desktop.
Genesis page template that adds posts in categories to a page
<?php
// Template Name: Page With Posts In Categories
//
// For Genesis framework. To use:
// 1) Create a page
// 2) Set the page template in the Page Attributes panel to this template
// 3) Turn off comments and trackbacks
// 4) Set a custom field on the page of query_args_category__and equal to the numeric ID of the category
// 5) Add additional custom fields with the same name but different category ID to display multiple categories
add_action('genesis_loop', 'custom_page_loop');
function custom_page_loop() {
global $post;
genesis_custom_loop( array(
'category__and' => get_post_meta( $post->ID, 'query_args_category__and' ),
'paged' => get_query_var('paged') ? get_query_var('paged') : 1,
'posts_per_page' => 10
) );
}
genesis()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment