Home Wordpress Archive URL rewriting
Reply: 1

Wordpress Archive URL rewriting

Ram
1#
Ram Published in 2017-11-12 06:55:19Z

I have custom wordpress post types with custom Taxonomies.

On the archive page I am trying to query 2 custom custom taxonomies.

Archive template is "archive-job_listing.php"

Wordpress URL is :

example.com/?job_listing_region=pune&job_listing_category=wordpress

WP rewrite code:

function ao_add_rewrite_rule() {
  add_rewrite_rule( 'pune/wordpress', '?job_listing_region=pune&job_listing_category=wordpress', 'top');
  flush_rewrite_rules();
}


add_action( 'init', 'ao_add_rewrite_rule');

The URL should come as

example.com/pune/wordpress

When I add above code nothing happens. I flushed the URL's (permalinks)

PS: I have written regex to make all the query strings as URL's working. But that was not working. So I wanted to get this simple one working.

Tarun Mahashwari
2#
Tarun Mahashwari Reply to 2017-11-12 13:48:23Z

Don't forget to click Save Changes in Permalinks Settings.

Try following:

function ao_add_rewrite_rule() {
  add_rewrite_rule( '^([^/]+)/([^/]+)/?', 'index.php?job_listing_region=$matches[1]&job_listing_category=$matches[2]', 'top');
  flush_rewrite_rules();
}


add_action( 'init', 'ao_add_rewrite_rule');
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.262188 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO