Last active
September 23, 2020 12:49
-
-
Save sukhikh18/d2c21db90fb4a4b59a8f88e570f9e899 to your computer and use it in GitHub Desktop.
Зарегистрировать свою страницу техническую страницу #WordPress
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 | |
/** | |
* Register //example.com/myurl/ query | |
*/ | |
add_filter('query_vars', 'seo18_query_vars'); | |
function seo18_query_vars($query_vars) { | |
$query_vars[] = 'variable'; | |
return $query_vars; | |
} | |
add_action('init', 'seo18_query_map', 1000); | |
function seo18_query_map() { | |
add_rewrite_rule("myurl", "index.php?variable=myurl", 'top'); | |
// flush_rewrite_rules(); | |
} | |
add_action('template_redirect', 'seo18_template_redirect', -10); | |
function seo18_template_redirect() { | |
$value = get_query_var('variable'); | |
if (empty($value)) return; | |
if ( false !== strpos($value, '?') ) { | |
list($value, $query) = explode('?', $value, 2); | |
parse_str($query, $query); | |
$_GET = array_merge($_GET, $query); | |
} | |
if ($value == 'myurl') { | |
// some body here | |
// do_action( '1c4wp_exchange' ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment