Last active
June 13, 2016 09:06
-
-
Save iamayaz/85aedd0b540c8e7550b23b55d8ba7b03 to your computer and use it in GitHub Desktop.
This file contains 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
//In function.php | |
// For Rewriting the URLS in WORDPRESS | |
add_filter('query_vars', 'add_state_var', 0, 1); | |
function add_state_var($vars){ | |
$vars[] = 'cp'; | |
return $vars; | |
} | |
add_filter('query_vars', 'add_singled_var', 0, 1); | |
function add_singled_var($vars){ | |
$vars[] = 'dcat'; | |
return $vars; | |
} | |
//http://example.com/digital-post-page/?cp=website-development-1/ change to http://example.com/digital-post-page/website-development-1/ | |
add_rewrite_rule('^digital-post-page/([^/]+)/?$','index.php?pagename=digital-post-page&cp=$matches[1]','top'); | |
add_rewrite_rule('^media-post-page/([^/]+)/?$','index.php?pagename=media-post-page&cp=$matches[1]','top'); | |
//http://example.com/why-do-you-need-one/?dcat=website-development-1 change to http://example.com/why-do-you-need-one/website-development-1 | |
add_rewrite_rule('^/([^/]+)/?$','index.php?dcat=$matches[1]','top'); | |
//In related page | |
//For getting the parameter in the page | |
echo get_query_var('dcat'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment