Skip to content

Instantly share code, notes, and snippets.

@nacin
Created June 11, 2012 19:57
Show Gist options
  • Save nacin/2912292 to your computer and use it in GitHub Desktop.
Save nacin/2912292 to your computer and use it in GitHub Desktop.
<?php
add_action( 'init', function() {
register_post_type( 'plugin', array(
'name' => 'Plugin',
'public' => true,
'rewrite' => false,
) );
} );
add_action( 'parse_request', function( $wp ) {
if ( isset( $wp->query_vars['name'] ) )
$wp->query_vars['post_type'] = 'plugin';
} );
add_filter( 'post_type_link', function( $post_link, $post ) {
if ( 'plugin' === $post->post_type )
return user_trailingslashit( home_url( $post->post_name ) );
return $post_link;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment