Copy below code in your function.php file.
Create post type with url taxonomy term
“our_homes” taxonomy terms and “property” Post type.
you must be assign category else it will error
<?php
add_action('init', 'wr_property');
function wr_property() {
register_taxonomy(
'our_homes',
'property',
array(
'label' => 'Taxonomy',
'singular_label' => 'taxonomy',
'hierarchical' => true,
'query_var' => true,
'rewrite' => array('slug' => 'taxonomyname'),
)
);
$labels = array(
'name' => _x('Property', 'post type general name'),
'singular_name' => _x('Property', 'post type singular name')
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => null,
'supports' => array('title','editor','thumbnail', 'excerpt'),
'rewrite' => array(
//'slug' => 'event',
'slug' => '/%our_homes%',
'with_front' => false //this is must be false for hide post type slug in url
),
'has_archive' => 'property'
);
register_post_type( 'property' , $args );
flush_rewrite_rules();
}
if($_POST)
{
add_action('save_post', 'save_details'); //create custom post type
}
// use this code for taxomy remove from url in custom post yep // in post type set 'with_front' => false
add_filter('post_type_link', 'property_permalink_structure', 10, 4);
function property_permalink_structure($post_link, $post, $leavename, $sample)
{
$our_homes_term = get_the_terms( $post->ID, 'our_homes' ); //our_homes taxonomy term
if($our_homes_term)
{
if ( false !== strpos( $post_link, '%our_homes%' ) ) {
$post_link = str_replace( '%our_homes%', array_pop( $our_homes_term )->slug, $post_link );
}
}
return $post_link;
}
?>