Advertisement
Guest User

Untitled

a guest
May 25th, 2012
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.74 KB | None | 0 0
  1.     add_action('init', 'register_property');
  2.    
  3.     function register_property() {
  4.    
  5.          register_taxonomy(
  6.             'property_order_id',
  7.             'property',
  8.             array(
  9.                 'label' => 'Property Order IDs',
  10.                 'singular_label' => 'Property Order IDs',
  11.                 'hierarchical' => true,
  12.                 'query_var' => true,
  13.                 'rewrite' => array('slug' => 'properties'),
  14.             )
  15.         );
  16.    
  17.         $labels = array(
  18.             'name' => _x('Property', 'post type general name'),
  19.             'singular_name' => _x('Property', 'post type singular name')
  20.         );
  21.    
  22.         $args = array(
  23.             'labels' => $labels,
  24.             'public' => true,
  25.             'publicly_queryable' => true,
  26.             'show_ui' => true,
  27.             'query_var' => true,
  28.             'capability_type' => 'post',
  29.             'hierarchical' => false,
  30.             'menu_position' => null,
  31.             'supports' => array('title','editor','thumbnail', 'excerpt'),
  32.             'rewrite' => array(
  33.                 //'slug' => 'event',
  34.                 'slug' => 'property/%property_order_id%'
  35.             )
  36.         );
  37.    
  38.         register_post_type( 'property' , $args );
  39.         flush_rewrite_rules();
  40.     }
  41.  
  42.     add_filter('post_type_link', 'property_permalink_structure', 10, 4);
  43.     function property_permalink_structure($post_link, $post, $leavename, $sample) {
  44.         if ( false !== strpos( $post_link, '%property_order_id%' ) ) {
  45.             $event_type_term = get_the_terms( $post->ID, 'property_order_id' );
  46.             $post_link = str_replace( '%property_order_id%', array_pop( $event_type_term )->slug, $post_link );
  47.         }
  48.         return $post_link;
  49.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement