Last active
August 29, 2015 14:01
-
-
Save leocaseiro/546d07e1d15e833daa0d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
functions.php | |
<?php | |
function custom_rewrite_rules() { | |
global $wp_rewrite; | |
// Define the param estado | |
add_rewrite_tag( '%estado%', '([^&]+)' ); | |
//For this result: empresas-garimpeiras/estado/pernambuco | |
add_rewrite_rule( '^empresas-garimpeiras/estado/([^/]+)/?$', 'index.php?&post_type=empresas-garimpeiras&estado=$matches[1]', 'top' ); | |
//For this result: empresas-garimpeiras/estado/pernambuco/page/2 | |
add_rewrite_rule( '^empresas-garimpeiras/estado/([^/]+)/page/([0-9]{1,})?/?$', 'index.php?&post_type=empresas-garimpeiras&estado=$matches[1]&paged=$matches[2]', 'top' ); | |
$wp_rewrite->flush_rules(); | |
} | |
add_action( 'init', 'custom_rewrite_rules' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment