Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #######
- register_post_type( 'px_land', array(
- 'labels' => array( 'name' => __( 'Направления' ) ),
- 'public' => true,
- 'show_ui' => true,
- 'capability_type' => 'post',
- 'publicly_queryable' => true,
- 'exclude_from_search' => false,
- 'hierarchical' => true,
- '_builtin' => false,
- 'query_var' => true,
- 'rewrite' => array( 'slug' => '%px_land_cat%', 'with_front' => false ),
- 'supports' => array( 'title', 'editor', 'custom-fields' )
- ));
- register_taxonomy( 'px_land_cat', array( 'px_land' ), array(
- 'labels' => array( 'name' => __( 'Категории' ) ),
- 'hierarchical' => true,
- 'show_ui' => true,
- 'query_var' => true,
- 'rewrite' => array( 'slug' => 'products', 'with_front' => false )
- ));
- #######
- **
- * PermaLink - Внедрение терма таксономии в структуру постоянных ссылок для произвольного типа записи.
- */
- add_filter( 'post_type_link', 'permalink_cpt_product', 10, 2 );
- function permalink_cpt_product( $link, $post ) {
- if ( $post->post_type === 'px_land' ) {
- if ( $terms = get_the_terms( $post->ID, 'px_land_cat' ) )
- $link = str_replace( '%px_land_cat%', current( $terms )->slug, $link );
- }
- return $link;
- }
Advertisement
Add Comment
Please, Sign In to add comment