Skip to content

Instantly share code, notes, and snippets.

@carlodaniele
Created March 16, 2016 20:29
Show Gist options
  • Save carlodaniele/8745bac8d290b9b17df0 to your computer and use it in GitHub Desktop.
Save carlodaniele/8745bac8d290b9b17df0 to your computer and use it in GitHub Desktop.
Add book-author rewrite rule
<?php
/**
* Add rewrite rules
*
* @link https://codex.wordpress.org/Rewrite_API/add_rewrite_rule
*/
function myplugin_rewrite_rule() {
add_rewrite_rule( '^book/book-author/([^/]*)/?', 'index.php?post_type=book&book-author=$matches[1]','top' );
}
add_action('init', 'myplugin_rewrite_rule', 10, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment