Support » Plugins » Hacks » posts archive page within custom taxonomy

  • Resolved WakkerMedia


    Hi there,

    I hope someone can help me with this! I would certainly appreciate it!!

    I am currently working on a project where a custom taxonomy Location is the centre of the website.

    This is used to create a location-based-search within the site.
    Now, I have created several custom posts which can all be connected to the location-taxonomy. When a visitor opens the website, his location gets selected with help of GeoLocation. After that, the visitor gets redirected to:

    This page shows information, news and events about the location. This is done with taxonomy-location.php.

    A custom post type company is connected to the location taxonomy. When a visitor click on the link: show companies, it needs to get redirected to:

    however, it gets redirected to:

    This is showing the content from index.php. In stead of archive-company.php.

    2 things, 1; there must be no redirection and 2; needs to address archive-company.php (and ofcourse, needs to address single-company.php).

    How can I achieve this?

    I hope someone can help me!!

    With kind regards,


Viewing 5 replies - 1 through 5 (of 5 total)
  • okay, I have fixed one issue! The url doesn’t get redirected anymore. I’ve achieved this by adding:

    'rewrite' => array( 'hierarchical' => true ),

    to my taxonomy.

    Now he only needs to show the archive-company.php file. In stead, he uses index.php.



    Perhaps by adding something like

    RewriteRule ^location/city/companies/(.*) archive-company.php?c=$1

    to htaccess?

    Hi there Aachen,

    That could work, but I thought that WordPress could handle this by its own… Like, when you would have a default blog, you can get the the content of with archive-company.php. And get a single post with company-name/ with single-company.php

    The only thing I want it to do is to use its custom taxonomy to create logical links. The taxonomy locations is used wihin all my custom posts.

    So you would get something like this:

    And again, I thought that WordPress could handle this by its own, because the way taxonomies can be used with posts.

    I hope someome could clarify this to me…

    Thnx in advance!!


    Moderator bcworkz


    The single-company.php file is only called as part of the WP default functioning if the requested post is a custom post type called ‘company’.

    If you were to create company pages instead of posts, you could specify a company.php file or similar as a template. The taxonomy template functionality only applies to archive-like listings with a template name such as taxonomy-location.php. See Template Hierarchy for more information.

    Otherwise, you should use the Rewrite API which ends up doing a rewriterule like in Aachen suggested, but has the added benefit of registering permalink tags if need be.

    Hi Bc!(And Aachen)

    Thnx for your reply. After searching for solutions in combination with the answers you both have given me, I came up with this:


    What I do is adding the ^locations/([^/]*)/companies and point it towards index.php?post_type=company

    I am not sure if this is the correct way to handle these kind of situations, but this does the trick for me!

    Thank you for helping me so far! I am marking this topic as solved.

    With kind regards,


Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘posts archive page within custom taxonomy’ is closed to new replies.