Skip to content

Instantly share code, notes, and snippets.

@wpmu-authors
Last active February 3, 2021 17:38
Show Gist options
  • Save wpmu-authors/6f0927b3bf9807e426c8778a3bf3a797 to your computer and use it in GitHub Desktop.
Save wpmu-authors/6f0927b3bf9807e426c8778a3bf3a797 to your computer and use it in GitHub Desktop.
option-activation.php
register_activation_hook( __FILE__, 'my_plugin_activation' );
function my_plugin_activation() {
add_option( 'my_plugin_activation','just-activated' );
}
add_action( 'admin_init','my_plugin_initialize' );
function my_plugin_initialize() {
if( is_admin() && get_option( 'my_plugin_activation' ) == 'just-activated' ) {
delete_option( 'my_plugin_activation' );
flush_rewrite_rules();
}
}
add_action( 'init', 'my_custom_post_type' );
function my_custom_post_type() {
$args = array(
'public' => true,
'label' => 'Board Games'
);
register_post_type( 'boardgames', $args );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment