WordPress.org

Ready to get started?Download WordPress

Forums

permalink for custom taxonomy template (12 posts)

  1. kingfloyd
    Member
    Posted 3 years ago #

    Hi Guys,

    Can you help me with my problem? I have created a custom taxonomy named "my_category" under the custom post type named "my_postype". the problem is every time I use the custom permalink /%postname%/ for displaying my custom taxonomy list using the template-my_category.php I'm having an 404 error not found. while if I use the default permalink it worked fine.
    btw here's how the link is viewed:

    default permalink: http://samplesite.com/?my_category=123 (working)
    custom permalink: http://samplesite.com/my_category/123 (404 error)

    hope yopu can helop me with this problem

    thanks in advance....

  2. Do normal pretty permalinks works? That is, for other pages, is it worknig?

  3. kingfloyd
    Member
    Posted 3 years ago #

    yes other pages work :| only the custom taxonomy template wont work if I assign the custom permalink.

  4. How did you create the custom taxonomy?

  5. Harish Chouhan
    Member
    Posted 3 years ago #

    Can you post the code used to create the custom taxonomy?
    And did you try to flush the permalinks?

  6. kingfloyd
    Member
    Posted 3 years ago #

    Hi,

    Thanks for visiting this page Guys. Here's my code in constructing the taxonomy

    register_taxonomy("my_category","my_post_type", array("hierarchical" => true, "label" => "My Category", 'show_ui' => true, 'query_var' => true, "singular_label" => "my_category", "rewrite" => true));

    also I added this code

    flush_rewrite_rules();

    on creating the custom post type

    thanks in advance.

  7. Harish Chouhan
    Member
    Posted 3 years ago #

    Hi,

    try adding this
    'with_front' => false

    If your blog permalink has any word in the front like "archives/post-name" then the above will help.

  8. kingfloyd
    Member
    Posted 3 years ago #

    Hi Harish,

    Thanks for the help appreciate it too much. But the problem still didn't work for me.

    register_taxonomy("free_video_category","free_video", array("hierarchical" => true, "label" => "Free Video Category", 'show_ui' => true, 'query_var' => true, "singular_label" => "free_video_category", "rewrite" => true , 'with_front' => true));

    I am using /%postname%/

    therefore to retrieve the page using the above custom permalink
    it will look like http://mysite.com/my_custom_taxonomy/post_slug

    tell me if I'm wrong by the way thanks.

  9. Harish Chouhan
    Member
    Posted 3 years ago #

    Hi,

    Well I just fixed a similar issue on my site. The code should run. But sometimes we either miss something small or its just old settings that conflict.

    If possible to share your website link that would be helpful, otherwise you may use below steps to debug:

    1. Disable and set permalinks to default
    2. Delete .htaccess file
    3. Test if your site works fine including the custom taxonomy
    4. Activate permalinks to the way you want
    5. And now test the site again
  10. kingfloyd
    Member
    Posted 3 years ago #

    Hello Harish,

    Thanks for the idea still doesn't solve my problem.

    here is the sample link on our site

    http://waytoa.com/_wp/free_video/sample-free-video-1/

    on the right side you will see The "categories | tag" through it you can navigate for the custom taxonomy list and it return 404.

    btw here's the password of the site if it required one

    pass:godbless123

    thanks

  11. PorridgeBear
    Member
    Posted 3 years ago #

    I ran into this tonight.

    I have a Page called Events. I have a custom Post Type called foo_event, and a custom taxonomy registerd to the custom post type called foo_event_taxonomy.

    I worked my theme so that on the Events page I am getting a list of the custom post type foo_event. And in the sidebar I used the custom-taxonomies-menu-widget to output my foo_event_taxonomy menu.

    However when clicking a taxonomy term I would land on a 404 despite having a taxonomy.php in place. I tried naming to taxonomy-foo_event_taxonomy.php but I still got a 404.

    On each change I would visit the Permalinks page to flush the settings but to no avail.

    I discovered what the problem was (even if I don't understand it)

    Both my custom post type and custom taxonomy registration functions specified a rewrite as

    'rewrite' => array('slug' => 'events', 'with_front' => false)

    Note that the slug is the same as the existing Events Page slug, also events.

    This seemed to be the cause - there is a clash going on with the existing page.

    The requirement here is that the Page at /events/ lists all post type = foo_event and that clicking the post title loads /events/some-post, or /events/2011/06/some-post etc.. but IF the rewrite is using the same slug as the page this does not work.

    I find this a little annoying. So I changed the rewrite rules for the custom type and the taxonomy to

    'rewrite' => array('slug' => 'event', 'with_front' => false)
    'rewrite' => array('slug' => 'event', 'with_front' => false)

    Refreshed by visting Permalinks. And now the result is that if I click a post title I go to

    /event/post-title

    And this works, despite being illogical because really it should be /events/post-title

    However, the taxonomy link /event/tag still does not work - 404.

    So I then discovered you can't have the same slug for the custom post as for the taxonomy either! Changed it to

    'rewrite' => array('slug' => 'event2', 'with_front' => false)

    Refreshed at Permalinks, and now

    /events/
    /event/my-post
    /event2/my-tag

    All work. But it's a real shame that the URLs are all completely illogical when all I want to do is move around under the logical space of /events/ - but WordPress cannot tell what you want from the same URL space I guess.

    So then I had an idea which works ... the slug can be whatever you want it to be - so I used

    'rewrite' => array('slug' => 'events/view', 'with_front' => false)
    'rewrite' => array('slug' => 'events/tag', 'with_front' => false)

    And now my links are super and are within the /events space

    /events/view/my-post
    /events/tag/my-tag

    Hope this helps - I've seen this issue all over the forums.

  12. Studio Vanguard
    Member
    Posted 2 years ago #

    That's a brilliant explanation PorridgeBear. I was having the exact same issue as outlined by the OP, however I when I changed my permalink settings to default, and then back to /%postname%/ my single-posttype.php templates all of a sudden decided to work. Hope this will save some people time and headaches!

Topic Closed

This topic has been closed to new replies.

About this Topic