Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter WakkerMedia

    (@wakkermedia)

    okay, I have fixed one issue! The url http://www.example.com/location/city/companies 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.

    Anyone?

    -thnx!!-

    Perhaps by adding something like

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

    to htaccess?

    Thread Starter WakkerMedia

    (@wakkermedia)

    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 http://www.example.com/companies/ with archive-company.php. And get a single post with http://www.example.com/companies/ 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:
    http://www.example.com/locations/location-name/companies/company-name
    And
    http://www.example.com/locations/location-name/educations/education-name
    Etc.

    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!!

    Douwe

    Moderator bcworkz

    (@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.

    Thread Starter WakkerMedia

    (@wakkermedia)

    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:

    `add_rewrite_rule();

    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,

    Douwe

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