Last active
August 29, 2015 14:24
-
-
Save cpaul007/a91a266598bf77a07159 to your computer and use it in GitHub Desktop.
Category archive page in gallery format
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 this opening PHP tag | |
/** | |
* Category Archive in Gallery Format | |
* | |
* @author Genesis Developer | |
* @license GPL-2.0+ | |
* @link http://genesisdeveloper.me/ | |
* @copyright Copyright ( c ) 2015, Genesis Developer. | |
*/ | |
//* Add the following codes in your functions.php file | |
//* Show all posts | |
add_action( 'pre_get_posts', 'gd_show_all_post_category_archive' ); | |
function gd_show_all_post_category_archive( $query ) { | |
if( ! is_admin() && is_category() && $query->is_main_query() ) { | |
$query->set( 'nopaging', true ); | |
return; | |
} | |
} | |
add_action( 'genesis_before_entry', 'gd_category_archive_template' ); | |
function gd_category_archive_template() { | |
if( ! is_category() ) | |
return; | |
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 ); | |
remove_action( 'genesis_entry_content', 'genesis_do_post_content' ); | |
remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 ); | |
remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 ); | |
remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 ); | |
remove_action( 'genesis_entry_footer', 'genesis_post_meta' ); | |
add_action( 'genesis_entry_header', 'genesis_do_post_image', 4 ); | |
add_action( 'genesis_entry_header', 'gd_do_post_publish_date', 9 ); | |
add_filter( 'genesis_attr_entry', 'gd_add_column_class' ); | |
add_filter( 'genesis_attr_entry-image', 'gd_entry_image_attr' ); | |
} | |
//* Display publish date | |
function gd_do_post_publish_date() { | |
printf( '<p class="entry-meta">%s</p>', do_shortcode( '[post_date]' ) ); | |
} | |
//* Add columns class | |
function gd_add_column_class( $attributes ) { | |
$attributes['class'] .= ' col-3'; | |
return $attributes; | |
} | |
//* Add class in img | |
function gd_entry_image_attr( $atts ) { | |
$atts['class'] = 'category-thumb'; | |
return $atts; | |
} | |
//* Remove filters | |
add_action( 'genesis_after_entry', 'gd_remove_filter' ); | |
function gd_remove_filter() { | |
if( ! is_category() ) | |
return; | |
remove_filter( 'genesis_attr_entry', 'gd_add_column_class' ); | |
remove_filter( 'genesis_attr_entry-image', 'gd_entry_image_attr' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment