Skip to content

Instantly share code, notes, and snippets.

@braddalton
Last active May 4, 2017 17:41
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 braddalton/77327a57d13194d82c3770d9862bde77 to your computer and use it in GitHub Desktop.
Save braddalton/77327a57d13194d82c3770d9862bde77 to your computer and use it in GitHub Desktop.
Filter Posts By Category https://wp.me/p1lTu0-gQm
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