Created
February 13, 2014 11:49
-
-
Save aderaaij/8973764 to your computer and use it in GitHub Desktop.
Create Custom post types for WordPress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* = New custom post-type | |
-------------------------------------------------------------- */ | |
add_action( 'init', 'create_post_type' ); | |
function create_post_type() { | |
register_post_type( 'events', | |
array( | |
'labels' => array( | |
'name' => __( 'Events' ), | |
'singular_name' => __( 'Events' ) | |
), | |
'public' => true, | |
'has_archive' => true, | |
'supports' => array( 'title', 'editor', 'author','tag','custom-fields', 'thumbnail' ), | |
'rewrite' => array( 'slug' => 'events', 'with_front' => false ), | |
'taxonomies' => array('post_tag'), | |
) | |
); | |
register_post_type( 'shop', | |
array( | |
'labels' => array( | |
'name' => __( 'Shop' ), | |
'singular_name' => __( 'Shop' ) | |
), | |
'public' => true, | |
'has_archive' => true, | |
'supports' => array( 'title', 'editor', 'author','tag','custom-fields', 'thumbnail' ), | |
'rewrite' => array( 'slug' => 'shop', 'with_front' => true ), | |
'taxonomies' => array('post_tag'), | |
) | |
); | |
} | |
/* = Create conditional post-type tags | |
-------------------------------------------------------------- */ | |
function is_post_type($type){ | |
global $wp_query; | |
if($type == get_post_type($wp_query->post->ID)) return true; | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment