Last active
March 26, 2017 00:23
-
-
Save kLOsk/0ef84068314d02a48f1b468d5eb15164 to your computer and use it in GitHub Desktop.
WordPress Snippets
This file contains 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 | |
//Remove CPT's | |
function dk_delete_post_type(){ | |
unregister_post_type( 'beers' ); | |
} | |
add_action('init','dk_delete_post_type'); | |
//Custom Permalinks and Rewrites | |
function wpa_show_permalinks( $post_link, $post ){ | |
if ( is_object( $post ) && $post->post_type == 'event' ){ | |
return str_replace( '/event/' , '/' , $post_link ); //remove event from permalinks | |
} | |
return $post_link; | |
} | |
add_filter( 'post_type_link', 'wpa_show_permalinks', 1, 2 ); | |
function dk_custom_rewrite() { | |
add_rewrite_rule('^events/([^/]*)/?', 'index.php?event=$matches[1]', 'top'); //make post available without event in url | |
} | |
add_action('init', 'dk_custom_rewrite'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment