Skip to content

Instantly share code, notes, and snippets.

@csbeck
Last active December 10, 2015 23:48
Show Gist options
  • Save csbeck/4511552 to your computer and use it in GitHub Desktop.
Save csbeck/4511552 to your computer and use it in GitHub Desktop.
Custom Archive listing page for use in Genesis. Includes pagination, showing custom fields content in posts which are in a category.
<?php
/**
* Template Name: New Tests Archive
*/
/** Remove original Primary Sidear -- add custom sidebar */
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
add_action( 'genesis_sidebar', 'csbeck_custom_sidebar_archive' );
function csbeck_custom_sidebar_archive() {
dynamic_sidebar( 'Menu_TestCatalog' );
}
get_header(); ?>
<?php genesis_before_content_sidebar_wrap(); ?>
<div id="content-sidebar-wrap">
<?php genesis_before_content(); ?>
<div id="content">
<?php genesis_before_loop(); ?>
<div class="post hentry">
<?php while (have_posts()) : the_post(); ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
<div class="entry-content">
<!-- show the content of the page -->
<?php the_content(); ?>
<!-- end of page content -->
<?php endwhile; ?>
<ul class="page_archive">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'cat' => 10,
'orderby' => 'title',
'order' => 'ASC',
'posts_per_page' => 20,
'paged' => $paged
);
query_posts($args);
?>
<div class="archive_page_pagination">
<?php
global $wp_query;
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages
) );
?></div>
<hr />
<?php while (have_posts()) : the_post(); ?>
<li class="archive_list_item"><h3><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
<?php the_meta(); ?>
</li>
<?php endwhile; ?>
</ul>
<hr />
<div class="archive_page_pagination">
<?php
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages
) );
?>
</div>
</ul>
</div><!-- end .entry-content -->
</div><!-- end .post -->
<?php genesis_after_loop(); ?>
</div><!-- end #content -->
<?php genesis_after_content(); ?>
</div><!-- end #content-sidebar-wrap -->
<?php genesis_after_content_sidebar_wrap(); ?>
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment