Skip to content

Instantly share code, notes, and snippets.

@leocaseiro
Last active August 29, 2015 14:01
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 leocaseiro/546d07e1d15e833daa0d to your computer and use it in GitHub Desktop.
Save leocaseiro/546d07e1d15e833daa0d to your computer and use it in GitHub Desktop.
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