Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

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/
share|improve this question
    
You need to check your permalink structure –  xLRDxREVENGEx May 20 '11 at 18:08
    
My permalink structure is as is '/%category%/%postname%/' –  Cioppino May 20 '11 at 18:22
    
can you post the contents of your .htaccess –  xLRDxREVENGEx May 20 '11 at 18:23
    
RewriteRule ^sellers/? pages/sellers/ RewriteRule ^buyers/? pages/buyers/ RewriteRule ^neighborhoods/? pages/category/neighborhoods/ –  Cioppino May 20 '11 at 18:33
    
Have you added the RewriteEngine on to your .htacces or did you add the rewrite rules that apache gave you? Can you post a link to your site if wanted to see if it affects everyone? I also updated your question just waiting for approval –  xLRDxREVENGEx May 20 '11 at 18:49
show 3 more comments

1 Answer 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.

share|improve this answer
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.