Ninja Forms for Custom Post Types

Today, I wanted to create an event post type and have it display a ninja form in a WordPress project I’m working on. It’s not difficult, but wasn’t obvious on first look. Semi-useful code follows:

 

function register_my_post_type() {
	$args = array(
		'public'               => true ,
		'capability_type'      => 'post' ,
		'register_meta_box_cb' => 'add_my_meta_box' ,
		
	);

	register_post_type( 'event' , $args );
}

add_action( 'init' , 'register_my_post_type' );

function add_my_meta_box( $post ) {
	if ( function_exists( 'ninja_forms_inner_custom_box' ) ) {
		add_meta_box(
			'ninja_forms_selector' ,
			__( 'Append A Ninja Form' , 'ninja-forms' ) ,
			'ninja_forms_inner_custom_box' ,
			'event' ,
			'side' ,
			'low'
		);
	}
}

Anywhere But Here

An entry for Writing 101, Day Two: A Room with a View. I was supposed to answer the question “If you could zoom through space in the speed of light, what place would you go to right now?” I couldn’t focus on the topic, but after reading a fellow writer’s post on the subject, this […]