Untitled - Posted on July Mon 4th 12:04 PM (Never Expires) - Format: php
  1. add_action('init', function(){
  2.    add_rewrite_rule( 'zipcode\/([0-9]{5})\/page\/([0-9]{1,})\/?', 'index.php?pagename=zipcode&zipcode=$matches[1]&page=$matches[2]', 'top' );
  3.    add_rewrite_rule( 'zipcode\/([0-9]{5})\/?', 'index.php?pagename=zipcode&zipcode=$matches[1]', 'top' );
  4.    add_rewrite_tag(
  5.         '%zipcode%',
  6.         '([^/]+)'
  7.     );
  8. });
  9.  
  10. function wpd_add_query_vars( $qvars ) {
  11.   $qvars[] = 'zipcode';
  12.   return $qvars;
  13. }
  14. add_filter( 'query_vars', 'wpd_add_query_vars' );
  15. // zipcode/62233/ works
  16. // zipcode/62233/page/1 goes to 404

New Paste

Paste Options

Recent Pastes

35 days ago

Untitled

43 days ago

Untitled

43 days ago

Untitled

43 days ago

Untitled

43 days ago

Untitled

43 days ago

Untitled

43 days ago

Untitled

393 days ago

Read file

406 days ago

Untitled

406 days ago

Untitled