Custom post type “jokes” plus my code snippet

My PHP code snippet for creating a Custom Post Type in WordPress 3.x or greater

I’ve been working on creating a custom post type for the site. Right now I’ve got one set as Jokes. Just need a few to add into those posts ;).

Check out the code I am using:

/* Actions */
	add_action( 'init', 'wpwag_init' );

/* Filters */

// Fire this during init
function wpwag_init() {
	$supports = array( 'title', 'editor', 'thumbnail', 'trackbacks', 'custom-fields', 'comments', 'page-attributes' );
	register_post_type( 'jokes',
		array(
			'label' 			=> 'Jokes',
			'singular_label' 	=> 'Joke',
			'public' 			=> true,
			'show_ui' 			=> true,
			'_builtin' 			=> false,
			'_edit_link' 		=> 'post.php?post=%d',
			'capability_type' 	=> 'post',
			'hierarchical' 		=> false,
			'rewrite' 			=> array( 'slug' => 'jokes', 'with_front' => false ),
			'query_var' 		=> true,
			//'taxonomies' 		=> array( 'post_tag', 'category' ),
			'supports' 			=> $supports,
			'menu_icon' 		=> get_stylesheet_directory_uri() . '/library/css/images/joker.png',
		)
	);
}

While I don’t find it necessary to share a mass tutorial on how,what and why. You can check out these awesome post tutorials on the custom post types.

  1. WP Codex
  2. Kovshenin
  3. Justin Tadlock
  4. WP Beginner

just to list a few..

Default image
Austin
πŸ’πŸ½β€β™‚οΈ Husband to Jeana. ⚾️ Dodgers obsessed. πŸ† World Series Champs. πŸ’» Lead Software Engineer @ Beachbody. πŸŒπŸΌβ€β™‚οΈScratch golfer. 🌱 Hydroponic Gardner. 🍿 Plex nerd. πŸš™ '15 WRX & '66 Corvette C2. 🐢 Missing my love Keiki; RIP 😒. Follow me on Twitter @TheFrosty & Instagram @TheFrosty.
Articles: 0

One comment

Leave a Reply

%d bloggers like this: