Last active
May 4, 2017 17:41
-
-
Save braddalton/77327a57d13194d82c3770d9862bde77 to your computer and use it in GitHub Desktop.
Filter Posts By Category https://wp.me/p1lTu0-gQm
This file contains 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
genesis_register_sidebar( array( | |
'id' => 'facet-categories', | |
'name' => __( 'Filter Categories', 'genesis' ), | |
'description' => __( 'Filter Posts by Categories.', 'genesis' ), | |
) ); | |
add_action( 'genesis_before_sidebar_widget_area', 'facet_categories_widget' ); | |
function facet_categories_widget() { | |
if ( is_home() || is_front_page() || genesis_is_blog_template() || is_archive() || is_search() ) { | |
genesis_widget_area( 'facet-categories', array( | |
'before' => '<div class="facet-categories widget-area">', | |
'after' => '</div>', | |
)); | |
} | |
} | |
add_filter( 'genesis_attr_content', 'add_facetwp_template_class' ); | |
// Add custom attributes for facetwp-template class to genesis main content element. | |
function add_facetwp_template_class( $attributes ) { | |
if ( is_home() || is_front_page() || genesis_is_blog_template() || is_archive() || is_search() ) { | |
$attributes['class'] .= ' facetwp-template'; | |
} | |
return $attributes; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment