WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a custom post type called featured_property and related taxonomy called locations and am having trouble getting the URL structure I want. I'm SO close but having trouble with the top level parent page. Here's the URL structure I want:

  • /featured-properties
  • /featured-properties/%location%/
  • /featured-properties/%location%/individual-post-name

Currently, the code I'm using works perfectly for the bottom 2 URLs.

If I have a taxonomy category of "denver," /featured-properties/denver and /featured-properties/denver/individual-post-name works.

However, if I navigate to the root page for my custom post type, /featured-properties, it redirects to /featured-properties/%location%/.

If I manually go to /featured-properties, I get a 404. Any help getting me there would be much appreciated.

// Custom post type and taxonomy for featured properties
function featured_post_type() {
        'labels' => array(
            'name' => __('Featured Properties', 'html5blank_webo'),
            'singular_name' => __('Featured Property', 'html5blank_webo'),
            'add_new' => __('Add New', 'html5blank_webo'),
            'add_new_item' => __('Add New Featured Property', 'html5blank_webo'),
            'edit' => __('Edit', 'html5blank_webo'),
            'edit_item' => __('Edit Featured Property', 'html5blank_webo'),
            'new_item' => __('New Featured Property', 'html5blank_webo'),
            'view' => __('View Featured Property', 'html5blank_webo'),
            'view_item' => __('View Featured Property', 'html5blank_webo'),
            'search_items' => __('Search Featured Properties', 'html5blank_webo'),
            'not_found' => __('No Featured Properties found', 'html5blank_webo'),
            'not_found_in_trash' => __('No Featured Properties found in Trash', 'html5blank_webo')
        'public' => true,
        'hierarchical' => true,
        'query_var' => true,
        'rewrite' => array( 'slug' => 'featured-properties/%location%', 'with_front' => true ),
        'has_archive' => true,
        'menu_position' => 20,
        'supports' => array(
        'can_export' => true,

function featured_taxonomy() {
            'hierarchical' => true,
            'label' => 'Locations',
            'query_var' => true,
            'rewrite' => array('slug' => 'featured-properties', 'with_front' => true)

add_action( 'init', 'featured_post_type' );
add_action( 'init', 'featured_taxonomy' );

// Rewrite rules for featured post type and tzxonomy
function filter_post_type_link($link, $post) {
    if ($post->post_type != 'featured_property')
        return $link;

    if ($cats = get_the_terms($post->ID, 'location'))
        $link = str_replace('%location%', array_pop($cats)->slug, $link);
    return $link;
share|improve this question
Why do you want a custom post type called "featured-properties"? Why don't you use a taxonomy term to set the featured properties? My logic says that "properties" should be the custom post type and "featured" a taxonomy term. Just a suggestion. Anyway, this question and answers will help you: wordpress.stackexchange.com/questions/114514/… – cybmeta Sep 23 '13 at 16:55
Thanks for the response. The site only lists featured properties... that's why the CPT named featured properties. In other words, there aren't properties listed that aren't featured. I'll take a look at the link you suggested... thank you. – user1771717 Sep 23 '13 at 19:01
Thank you! That article fixed it for me. – user1771717 Sep 23 '13 at 20:06
You are wellcome – cybmeta Sep 24 '13 at 6:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.