• Resolved Tatiane Pires

    (@tatianeps)


    Searching around the support topics, I’ve found one with a request similar to what I need [link 1 below], but that topic is closed.

    My blog posts are in Portuguese, so I created a CPT named ‘postsEN’, with slug ‘en’, for a section on my blog where I intend to write content in English.

    To create a category on default posts doesn’t make it, because I don’t want posts in English to be listed with posts in Portuguese. I don’t want another blog either, that’s why I’m not going to use the network feature for this purpose.

    I published a dummy ‘Hello World!’ post under the new CPT:
    tatianepires.com.br/en/hello-world/

    The links for single posts are OK. The problem is I was expecting that the following links would work too:
    tatianepires.com.br/en/category/my-new-category
    tatianepires.com.br/en/tag/new-tag

    The category and the tag above are displayed for “Hello World!” on /wp-admin/edit.php?post_type=postsen, but the links doesn’t work.

    Code for register-custom-post-types.php with register_taxonomy for both ‘postsen_category’ (with slug ‘category’) and ‘postsen_tag’ (with slug ‘tag’):
    http://pastebin.com/8iRm0pSC

    I’m using this file as a mu-plugin. I have already used “Save Changes” on /wp-admin/options-permalink.php to flush rewrite after upload the file to the server, but the links are not working.

    What am I missing to make this code work?
    I need some help to fix it. Tks.

    [1] Logical permalink structure with custom post and taxonomies

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Tatiane Pires

    (@tatianeps)

    Even though the category “My New Category” (slug my-new-category) and tag “New Tag” (slug new-tag) added to the test post “Hello World!” are listed on /edit.php?post_type=postsen screen, they don’t show up when the post is viewed in the blog, on the link tatianepires.com.br/en/hello-world/, generated by single-postsen.php. I have included get_the_category_list() and get_the_tag_list() on single-postsen.php to test what categories and tags were listed, but there is nothing.

    How is it that categories and tags are listed for the CPT on the admin side, but doesn’t show up on the blog?

    When I write that tatianepires.com.br/en/category/my-new-category and
    tatianepires.com.br/en/tag/new-tag aren’t working, I mean that they lead to Error 404 page as if there were no posts.

    I need to check:
    1) Are the rewrites on register-custom-post-types.php ok? Are the links above correct?
    2) If 1 is ok (I still think it isn’t, but I can’t figure it out yet), why is this Error 404 page thing happening when there is one post assigned to the category and the tag I mentioned.

    Richard

    (@richardcoffee)

    Without seeing the code you are using, it is difficult to offer any specific advice.

    I would venture to suggest that your rewrites should be ‘en/category’ for ‘postsen_category’, and ‘en/tag’ for ‘postsen_tag’. This alone may not be enough to get it to work, depending on what else you are doing. For instance, you may (or may not) need ‘taxonomy-postsen_category.php’ and ‘taxonomy-postsen_tag.php’ pages.

    Maybe someone else here can offer ore advice. Good luck!

    richard

    Thread Starter Tatiane Pires

    (@tatianeps)

    The code is on the pastebin link in my first post above.

    Code for register-custom-post-types.php with register_taxonomy for both ‘postsen_category’ (with slug ‘category’) and ‘postsen_tag’ (with slug ‘tag’):
    http://pastebin.com/8iRm0pSC

    I’ll try out your suggestions, Richard, and post about the results.

    Richard

    (@richardcoffee)

    Wow, with the other links, I must have missed the pastebin one. Dang.

    Having looked over the pastebin, I have noticed a few things:

    The post_type array has two ‘rewrite’ indexes. Not sure which one that PHP will assign to the array, but you will only end up with one of them.

    I notice you are passing the ‘taxonomies’ array also. I am not sure but reading the codex seems to indicate the taxonomies have to have already been registered prior to using passing that array. Personally, I always opt to use register_taxonomy_for_object_type instead.

    I normally only pass the slug in the taxonomy rewrite array. Your value for ‘with_front’ is the default value, while ‘feeds’ and ‘pages’ are, as far as I aware, not valid values for the taxonomy rewrite array. I would think that wordpress just ignore those two.

    Hope this is helpful.

    Thread Starter Tatiane Pires

    (@tatianeps)

    Solved!
    Thank you, Richard! Your comments on this issue helped a lot. =D

    I updated the pastebin link with the working code.
    http://pastebin.com/8iRm0pSC

    Thread Starter Tatiane Pires

    (@tatianeps)

    I thought the topic was solved. It’s almost solved.

    The links for taxonomy archive pages are OK. Now I have these:
    tatianepires.com.br/en/ [all posts of postsen CPT]
    tatianepires.com.br/en/hello-world/ [post]
    tatianepires.com.br/en/category/my-new-category [taxonomy:category]
    tatianepires.com.br/en/tag/new-tag [taxonomy:tag]

    But archive pages for day, month and year are going to page 404:strong
    tatianepires.com.br/en/2015 [yearly archive]
    tatianepires.com.br/en/2015/05 [monthly archive]
    tatianepires.com.br/en/2015/05/08 [daily archive]

    I’m trying to figure this out.
    Help is appreciated. Tks.

    Thread Starter Tatiane Pires

    (@tatianeps)

    I’ll mark this topic as solved, because my first question is in fact solved, and I’ll open another support topic for the second issue: archive pages for CPT.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to make URLs work for categories and tags of custom post types’ is closed to new replies.