wordpress url rewriting for custom template

I am very new to wordpress and getting so confused that how to create custom url rewriting for wordpress custom template. I have also try to find out it on google but no luck. I can’t find proper solution for this.

Here is my current url structure:

Read More
http://example.com/chiptuning/search/?brand=Audi

using custom url rewriting I want to convert it to

http://example.com/chiptuning/search/brand/audi

or it may be

http://example.com/chiptuning/search/Audi

Please also mention where to put code.

UPDATE

The answer provided by @Mike Lewis is already used by me but it doesn’t provide what I am looking for, anyway thanks for reply @Mike Lewis.

Any one else have any suggestion for the question? I need it fast, please.

Thanx in advance.

Related posts

Leave a Reply

1 comment

  1. WordPress does its own magic for finding which template file to use. If you know about rewrite rules, you can look through these pages:

    OR, here are a few simpler solutions:

    Using Hierarchical Pages

    site.com/page1/sub-page/sub-page/

    You must add the pages using a browser through /wp-admin/, where you can then set its parent page. You may also choose a specific template (PHP theme file) to use (see: Theme Development and scroll down to Custom Page Templates).

    Use Hierarchical Categories

    You could also use hierarchical categories to tag posts, and then list them on the category archive pages. For example:

    You could have site.com/category/brand/audi/ (note, you can change the ‘category’ base part of this url in the wordpress settings).

    You can create template files for the various tag archive pages: category-brand.php would load for the site.com/category/brand/ url, and category-audi.php would load for the site.com/category/brand/audi/ url.

    Note: Depending on how dynamic your site needs to be, you may need to skip using a category-{tag}.php, so that it falls through to a generic category.php. In this case, I believe both of the above urls would use the generic category.php (in the absence of a more specific template file – Template Hierarchy scroll down to see the template hierarchy diagram).

    This would prevent you from having to create a separate file for each individual tag. Use the get_query_var() method to get the specific category tag.

    Last but not least

    If you’re still stumped, there’s another way to slice and dice the urls, without using rewrite rules. BuddyPress (a plugin for wordpress) has a function that chops the url into pieces (/one/two/three/) and then uses these within PHP. I’m not sure exactly how this works, but if you wanted to take a look, you can google/download BuddyPress, and look in the buddypress/bp-core/bp-core-catchuri.php file.

    Here’s the doc block:

    /**
     * Analyzes the URI structure and breaks it down into parts for use in code.
     * BuddyPress can use complete custom friendly URI's without the user having to
     * add new re-write rules. Custom components are able to use their own custom
     * URI structures with very little work.
     *
     * @package BuddyPress Core
     * @since BuddyPress (1.0)
     *
     * The URI's are broken down as follows:
     *   - http:// domain.com / members / andy / [current_component] / [current_action] / [action_variables] / [action_variables] / ...
     *   - OUTSIDE ROOT: http:// domain.com / sites / buddypress / members / andy / [current_component] / [current_action] / [action_variables] / [action_variables] / ...
     *
     *  Example:
     *    - http://domain.com/members/andy/profile/edit/group/5/
     *    - $bp->current_component: string 'xprofile'
     *    - $bp->current_action: string 'edit'
     *    - $bp->action_variables: array ['group', 5]
     *
     */
    function bp_core_set_uri_globals() {