Clash of the rewrites

I have a category called ‘neighborhoods’. I also have child categories within ‘neighborhoods’ E.G. Lakewood, Highland Park…

When I click ‘highland park’ the url is /pages/category/neighborhoods/highland-park

Read More

How can I change the htacces rules so that when viewing highland park the url would be neighborhoods/highland park/

I also have a post titled ‘highland park’ in order to have the neighborhoods page generate the ‘highland park’ category. But when you click it takes you to the single post page.

I have a rewrite rule that works when you go to /neighborhoods/ it rewrites pages/category/neighbhorhoods/

but going to the child category brings you the post.

EDIT: here is the contents of the .htaccess file

RewriteRule ^sellers/? pages/sellers/
RewriteRule ^buyers/? pages/buyers/
RewriteRule ^neighborhoods/? pages/category/neighborhoods/

Related posts

Leave a Reply

1 comment

  1. Your best option is to register neighborhoods as a custom taxonomy and use that instead of categories. In your theme’s functions.php file, you just need to add:

    function neighborhoods_init() {
        // create a new taxonomy
        register_taxonomy(
            'neighborhoods',
            'post',
            array(
                'label' => __( 'Neighborhoods' ),
                'hierarchical' => true
            )
        );
    }
    add_action( 'init', 'neighborhoods_init' );
    

    Next, go into your permalinks settings page and click save to be sure they get refreshed. Now when you edit posts, you’ll have a new box in the sidebar for Neighborhoods. Your neighborhoods will now have links starting with /neighborhoods/! Of course, you’ll have to port over your categories (and you’ll probably want to remove the old categories to avoid confusion).

    You have other options too when registering the taxonomy; see http://codex.wordpress.org/Function_Reference/register_taxonomy for all the details. For instance, you might consider adding 'rewrite' => array( 'slug' => 'neighborhood' ) to the array since each neighborhood will be singular, not plural, making the URLs e.g. /neighborhood/highland-park/ (hey, I’m nit-picky).

    Note: be sure to remove RewriteRule ^neighborhoods/? pages/category/neighborhoods/ from your htaccess file, too.