init
is an action hook that gets fired after WordPress has finished loading but before any HTTP headers are sent.
add_action('init', 'process_post_data');
function process_post_data() {
if( isset( $_POST ) ) {
// process $_POST data here
}
}
add_action('init', 'process_get_data');
function process_get_data() {
if( isset( $_GET ) ) {
// process $_GET data here
}
}
add_action( 'init', function() {
register_post_type( 'event', array(
'public' => true,
'label' => 'Events'
);
);
});
Registers a new custom post type with a label Events
and a slug event