Skip to content

Instantly share code, notes, and snippets.

@sukhikh18
Last active September 23, 2020 12:49
Show Gist options
  • Save sukhikh18/d2c21db90fb4a4b59a8f88e570f9e899 to your computer and use it in GitHub Desktop.
Save sukhikh18/d2c21db90fb4a4b59a8f88e570f9e899 to your computer and use it in GitHub Desktop.
Зарегистрировать свою страницу техническую страницу #WordPress
<?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