Skip to content

Instantly share code, notes, and snippets.

@dancameron
Created May 8, 2012 15:30
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 dancameron/2636341 to your computer and use it in GitHub Desktop.
Save dancameron/2636341 to your computer and use it in GitHub Desktop.
GBS :: Add custom rewrite rules for filtering vouchers
<?php
/**
* Add custom rewrite rules for filtering vouchers
*
* @param array $vars
* @return array
*/
public function custom_mngt_voucher_rewrite_rules( $rules ) {
global $wp_rewrite;
$rules['cupones/caducados(/page/?([0-9]{1,}))?/?$'] = 'index.php?post_type='.Group_Buying_Voucher::POST_TYPE.'&paged='.$wp_rewrite->preg_index( 2 ).'&'.Group_Buying_Vouchers::FILTER_QUERY_VAR.'='.Group_Buying_Vouchers::FILTER_EXPIRED_QUERY_VAR;
$rules['cupones/usados(/page/?([0-9]{1,}))?/?$'] = 'index.php?post_type='.Group_Buying_Voucher::POST_TYPE.'&paged='.$wp_rewrite->preg_index( 2 ).'&'.Group_Buying_Vouchers::FILTER_QUERY_VAR.'='.Group_Buying_Vouchers::FILTER_USED_QUERY_VAR;
$rules['cupones/activos(/page/?([0-9]{1,}))?/?$'] = 'index.php?post_type='.Group_Buying_Voucher::POST_TYPE.'&paged='.$wp_rewrite->preg_index( 2 ).'&'.Group_Buying_Vouchers::FILTER_QUERY_VAR.'='.Group_Buying_Vouchers::FILTER_ACTIVE_QUERY_VAR;
return $rules;
}
add_filter( 'gb_rewrite_rules', 'custom_mngt_voucher_rewrite_rules', 10, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment