Skip to content

Instantly share code, notes, and snippets.

@Clorith
Created May 3, 2013 10:38
Show Gist options
  • Save Clorith/5508431 to your computer and use it in GitHub Desktop.
Save Clorith/5508431 to your computer and use it in GitHub Desktop.
<?php
function create_rewrites() {
add_rewrite_rule(
'pamelding/([^/]+)/?$',
'index.php?pagename=pamelding&courseid=$matches[1]',
'top'
);
add_rewrite_rule(
'kursdetaljer/([^/]+)/([^/]+)/?$',
'index.php?pagename=kursdetaljer&courseid=$matches[1]',
'top'
);
add_rewrite_rule(
'kursliste/([^/]+)/?$',
'index.php?pagename=kursliste&coursetype=$matches[1]',
'top'
);
}
function create_query_vars( $vars ) {
$vars[] = 'courseid';
$vars[] = 'coursetype';
return $vars;
}
add_action( 'generate_rewrite_rules', 'create_rewrites' );
add_action( 'after_switch_theme', 'flush_rewrite_rules' );
add_action( 'query_vars', 'create_query_vars' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment