Skip to content

Instantly share code, notes, and snippets.

@elhardoum
Created March 25, 2016 01:45
Show Gist options
  • Save elhardoum/47a287202c5fba2fe776 to your computer and use it in GitHub Desktop.
Save elhardoum/47a287202c5fba2fe776 to your computer and use it in GitHub Desktop.
<?php
add_action('init', function() {
// rewriting site.ext/index.php?se_random_post=1 to site.ext/random/
add_rewrite_rule(
'random/?$',
'index.php?se_random_post=1',
'top'
);
});
add_filter('query_vars', function($vars) {
// saving the query variable for the rewrite rule
$vars[] = "se_random_post";
return $vars;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment