1

So let's say i register a custom taxonomy called:

Clients

With a few terms such as: Microsoft, IBM, Apple

Under a CPT (custom post type) called projects:

Permalinks

/%year%/%monthnum%/%taxonomy%/%postname%/ this is the structure i am using;

http://www.example.com/projects/ - Displays All posts under 'projects'

http://www.example.com/projects/clients/ Displays a 404

http://www.example.com/projects/clients/ibm/ displays all posts under projects with the term ibm

How can i get Wordpress to display an Index of all the posts under Clients? so for example if the user visited /projects/clients/ all the posts with Microsoft, Apple and IBM would be displayed.

I know a method is to use a page and then query into the page, but in essence of SEO, and relevance, i can not name the page-slug something else.

Thanks in advance.

2 Answers 2

2

You need to write a custom rule. I did similar stuff for a recent project. Create a template, and assign it to a page, with slug as 'clients' (or anything you like, but change the slug in the following rule as well). Try the following code, use functions.php:

add_action('init', 'custom_rule');
function custom_rule()
{
    global $wp, $wp_rewrite;
    $wp_rewrite->add_rule('^projects/clients/', 'index.php?pagename=clients', 'top');
}

Then on that template, form a custom query with your desired params (clients taxonomy) and loop through it.

Note: After you put the above code in your functions.php file, go to Settings > Permalinks, and click on save.

Hope this helps (I recommend you try it locally first)!

2
  • where are you including that code Rutwick ?
    – Xavier
    Oct 3, 2011 at 12:29
  • Please check my edited answer... Oct 4, 2011 at 4:51
0

You cannot access the clients location because its not a term, its your taxonomy base.

http://www.example.com/projects/clients/ is taxonomy base. Its like accessing http://www.example.com/tags/ which doesn't work.

http://www.example.com/projects/clients/ibm/ is taxonomy term URL. Its like accessing http://www.example.com/tags/example which works.

If you want to access /clients/ URL then you should create a page with custom template that can display the contents of all posts under /clients/ taxonomy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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