Last active
September 5, 2020 07:10
-
-
Save iamRahul1973/1d786c77bef907fd0cb088c699117da9 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
<?php | |
/* ------------------------------------------------------ | |
* | REWRITE URL FOR PODCASTS | |
* ------------------------------------------------------ | |
* | |
* The Url would be, siteurl.com/podcasts/podcast-slug | |
* | |
* ------------------------------------------------------ */ | |
// Add a Rewrite Tag | |
function custom_rewrite_tag() { | |
add_rewrite_tag('%podcasts%', '([^&]+)'); | |
} | |
add_action('init', 'custom_rewrite_tag', 10, 0); | |
// Add a Rewrite Rule | |
function custom_rewrite_rule() { | |
add_rewrite_rule('^podcasts/([^/]*)/?','index.php?page_id={your-page-id}&podcasts=$matches[1]','top'); | |
} | |
add_action('init', 'custom_rewrite_rule', 10, 0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment