Advertisement
mikelittle

Solicitor CPT and Taxonomy

Oct 18th, 2012
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.60 KB | None | 0 0
  1. <?php
  2. add_action( 'init', 'tdd_create_custom_post_type' );
  3. function tdd_create_custom_post_type() {
  4.     $labels = array( 'name' => _x( 'solicitors', 'post type general name' ),
  5.                      'singular_name' => _x( 'solicitor', 'post type singular name' ),
  6.                      'add_new' => _x( 'New solicitor', 'add new singular name' ),
  7.                      'add_new_item' => __( 'Add New solicitor' ),
  8.                      'edit_item' => __( 'Edit solicitor' ),
  9.                      'new_item' => __( 'New solicitor' ),
  10.                      'view_item' => __( 'View solicitor' ),
  11.                      'search_items' => __( 'Search solicitors' ),
  12.                      'not_found' =>  __( 'No solicitors Found' ),
  13.                      'not_found_in_trash' => __( 'No solicitors found in Trash' ),
  14.                    );
  15.     $args = array( 'labels' => $labels,
  16.                    'public' => true,
  17.                    'publicly_queryable' => true,
  18.                    'show_ui' => true,
  19.                    'query_var' => true,
  20.                    'rewrite' => true,
  21.                    'has_archive' => 'solicitors',
  22.                    'capability_type' => 'post',
  23.                    'hierarchical' => true,
  24.                    'show_in_nav_menus' => true,
  25.                    'menu_position' => 100, // last block
  26.                    'supports' => array( 'title', 'editor', 'revisions', 'shortlink' )
  27.                  );
  28.  
  29.     register_post_type( 'solicitor', $args );
  30.  
  31.     $tax_labels = array(
  32.                         'name' => _x( 'Specialities', 'taxonomy general name' ), // there will only be one
  33.                         'singular_name' => _x( 'Speciality', 'taxonomy singular name' ),
  34.                         'search_items' =>  __( 'Search specialities' ),
  35.                         'popular_items' => __( 'Popular specialities' ),
  36.                         'all_items' => __( 'All specialities' ),
  37.                         'parent_item' => null,
  38.                         'parent_item_colon' => null,
  39.                         'edit_item' => __( 'Edit speciality' ),
  40.                         'update_item' => __( 'Update speciality' ),
  41.                         'add_new_item' => __( 'Add New speciality' ),
  42.                         'new_item_name' => __( 'New speciality Name' ),
  43.                         'separate_items_with_commas' => __( 'Separate specialities with commas' ),
  44.                         'add_or_remove_items' => __( 'Add or remove specialities' ),
  45.                         'choose_from_most_used' => __( 'Choose from the most used specialities' )
  46.                        );
  47.     $tax_args = array(
  48.                       'labels' => $tax_labels,
  49.                       'hierarchical' => false,
  50.                       'show_ui' => true,
  51.                       'query_var' => true,
  52.                       'rewrite' => array( 'slug' => 'solicitor-speciality' ),
  53.                      )
  54.     register_taxonomy( 'speciality', 'solicitor', $tax_args );
  55. }
  56.  
  57. add_filter( 'the_content', 'tdd_extra_content' );
  58. function tdd_extra_content( $content ) {
  59.     global $post;
  60.     if ( isset( $post->post_type ) && ( 'solicitor' == $post->post_type ) )
  61.         return $content . get_the_term_list( $post->ID, 'speciality', 'Specialities: ', ', ' , '' );
  62.     return $content;
  63. } //end extra_content
  64. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement