Created
October 28, 2017 17:49
-
-
Save anwerashif/51961b82eec64ae06482d8421e656ee3 to your computer and use it in GitHub Desktop.
Archive Template for Custom Post Type in Genesis
This file contains hidden or 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 | |
// Do NOT include the opening PHP tag | |
/** | |
* Template Name: Code Snippets Archive | |
* Description: Used as a page template to show custom-post-type 'code' | |
*/ | |
// Add 'code_snippet' ID | |
function be_site_inner_attr( $attributes ) { | |
// Add an id of 'code_snippet' for accessible skip links | |
$attributes['id'] = 'code_snippet'; | |
// Add the attributes from .entry, since this replaces the main entry | |
$attributes = wp_parse_args( $attributes, genesis_attributes_entry( array() ) ); | |
return $attributes; | |
} | |
add_filter( 'genesis_attr_body', 'be_site_inner_attr' ); | |
// Remove standard post content output | |
remove_action( 'genesis_post_content', 'genesis_do_post_content' ); | |
remove_action( 'genesis_entry_content', 'genesis_do_post_content' ); | |
add_action( 'genesis_entry_content', 'code_archive_content' ); | |
add_action( 'genesis_post_content', 'code_archive_content' ); | |
/** | |
* This function outputs sitemap-esque columns displaying all pages, | |
* @author Anwer Ashif | |
* @link http://rainastudio.com/ | |
*/ | |
function code_archive_content() { ?> | |
<h1><?php _e( 'All Code Snippets:', 'genesis' ); ?></h1> | |
<ul> | |
<?php wp_get_archives( 'type=postbypost&post_type=code' ); ?> | |
</ul> | |
<?php | |
} | |
genesis(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment