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',
			'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..


πŸ’πŸ½β€β™‚οΈ Husband to Jeana.
⚾️ Dodgers & Brewers.
πŸ’» PHP Engineer.
πŸŒπŸΌβ€β™‚οΈGolfer; ~14 HDC.
🌱 Hydroponic Gardner.
🍿 Plex nerd.
πŸš™ '15 WRX, '22 Model 3 LR, & '66 Corvette C2.

Follow me on Twitter @TheFrosty & Instagram @TheFrosty.

Articles: 292

One comment

Comments are closed.