The text below is selected, press Ctrl+C to copy to your clipboard. (⌘+C on Mac) No line numbers will be copied.
add_action('init', function(){
add_rewrite_rule( 'zipcode\/([0-9]{5})\/page\/([0-9]{1,})\/?', 'index.php?pagename=zipcode&zipcode=$matches[1]&page=$matches[2]', 'top' );
add_rewrite_rule( 'zipcode\/([0-9]{5})\/?', 'index.php?pagename=zipcode&zipcode=$matches[1]', 'top' );
add_rewrite_tag(
'%zipcode%',
'([^/]+)'
);
});
function wpd_add_query_vars( $qvars ) {
$qvars[] = 'zipcode';
return $qvars;
}
add_filter( 'query_vars', 'wpd_add_query_vars' );
// zipcode/62233/ works
// zipcode/62233/page/1 goes to 404