Last active
October 12, 2015 14:27
-
-
Save joehoyle/4040324 to your computer and use it in GitHub Desktop.
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
<?php | |
hm_rewrite_rule( array( | |
'regex' => '^reviews/([^/]+)/?', // a review category page | |
'query' => 'review_category=$matches[1]&', | |
'template' => 'review-category.php', | |
'request_callback' => function( WP $wp ) { | |
// if the review category is "laptops" then only show items in draft | |
if ( $wp->query_vars['review_category'] == 'laptops' ) | |
$wp->query_vars['post_status'] = 'draft'; | |
}, | |
'query_callback' => function( WP_Query $query ) { | |
//overwrite is_home because WordPress gets it wrong here | |
$query->is_home = false; | |
}, | |
'body_class_callback' => function( $classes ) { | |
$classes[] = get_query_var( 'review_category' ); | |
return $classes; | |
}, | |
'title_callback' => function( $title, $seperator ) { | |
return review_category . ' ' . $seperator . ' ' . $title; | |
} | |
) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment