-
-
Save srikat/63e37184312d090deb50 to your computer and use it in GitHub Desktop.
FacetWP in Genesis. http://sridharkatakam.com/facetwp-genesis/
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
add_filter( 'genesis_attr_content', 'custom_attributes_content' ); | |
/** | |
* Add the class needed for FacetWP to main element. | |
* | |
* Context: Posts page, all Archives and Search results page. | |
* | |
* @author Sridhar Katakam | |
* @link http://sridharkatakam.com/facetwp-genesis/ | |
*/ | |
function custom_attributes_content( $attributes ) { | |
if ( is_home() || is_archive() || is_search() ) { | |
$attributes['class'] .= ' facetwp-template'; | |
} | |
return $attributes; | |
} |
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
add_action( 'loop_end', 'sk_replace_genesis_pagination' ); | |
/** | |
* Replace Genesis' Pagination with FacetWP's. | |
* | |
* Context: Posts page, all Archives and Search results page. | |
* | |
* @author Sridhar Katakam | |
* @link http://sridharkatakam.com/facetwp-genesis/ | |
*/ | |
function sk_replace_genesis_pagination() { | |
if ( ! ( is_home() || is_archive() || is_search() ) ) { | |
return; | |
} | |
remove_action( 'genesis_after_endwhile', 'genesis_posts_nav' ); | |
add_action( 'genesis_after_endwhile', 'sk_posts_nav' ); | |
} | |
function sk_posts_nav() { | |
if ( ! function_exists( 'facetwp_display' ) ) { | |
return; | |
} | |
// Display pagination | |
echo facetwp_display( 'pager' ); | |
} |
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
//* Add Archive Settings option to Tutorials CPT | |
add_post_type_support( 'tutorials', 'genesis-cpt-archives-settings' ); | |
//* Register Tutorials widget area | |
genesis_register_sidebar( array( | |
'id' => 'tutorials-sidebar', | |
'name' => __( 'Tutorials Sidebar', 'themename' ), | |
'description' => __( 'This widget area appears in the Primary Sidebar position on Tutorials Archive.', 'themename' ), | |
) ); | |
add_action( 'genesis_after_header', 'sk_custom_tutorials_sidebar' ); | |
/** | |
* Replace Primary Sidebar with Tutorials Sidebar. | |
* | |
* Context: Tutorials CPT archive page. | |
* | |
* @author Sridhar Katakam | |
* @link http://sridharkatakam.com/display-custom-widget-area-primary-sidebar-location-genesis/ | |
*/ | |
function sk_custom_tutorials_sidebar() { | |
if ( ! ( is_post_type_archive( 'tutorials' ) ) ) { | |
return; | |
} | |
// Remove the Primary Sidebar from the Primary Sidebar area. | |
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' ); | |
// Place custom Sidebar into the Primary Sidebar area. | |
add_action( 'genesis_sidebar', 'sk_genesis_do_sidebar' ); | |
} | |
function sk_genesis_do_sidebar() { | |
dynamic_sidebar( 'tutorials-sidebar' ); | |
} |
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
.facetwp-selections { | |
margin-bottom: 30px; | |
} |
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
[facetwp facet="tutorials_search"] | |
<h4>Difficulty Level</h4> | |
[facetwp facet="difficulty_level"] | |
<h4>Category</h4> | |
[facetwp facet="tutorial_categories"] | |
[facetwp selections="true"] | |
<button value="Reset" onclick="FWP.reset()" />Reset All</button> |
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
/* FacetWP | |
--------------------------------------------- */ | |
.facetwp-pager { | |
clear: both; | |
margin: 40px 0; | |
} | |
.facetwp-pager .facetwp-page { | |
background-color: #333; | |
color: #fff; | |
font-size: 16px; | |
padding: 8px 12px; | |
} | |
.facetwp-pager .facetwp-page.active { | |
font-weight: 300; | |
background-color: #e5554e; | |
} | |
.facetwp-pager .facetwp-page:hover { | |
background-color: #e5554e; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment