• Resolved Valentin E

    (@valentin-e)


    Hello!
    I am using your plugin.
    1) First, I created post type “service” (and writing posts),then,
    2) taxonomy “services__types“,
    3) and 3 categories (are assigned ID`s 18,19,20).

    Post type <strong>service</strong> is worked correctly, template <strong>single-service.php</strong> is defined.

    But, when I am going to page “[site_url]services__types/individual-businessmans_services/" (cat_ID = 18)
    — templates are named: category-18.php, archive-service.php is ignored.
    — instead of this defined template from <strong>index.php</strong> or <strong>category.php </strong> (if it )

    Addition, function
    echo get_category_link(18); (or 19, 20) returned empty string, as though there is no such categories.

    Please explain: why this categories of user-taxonomy is working incorrectly unlike default categories («echo get_category_link(8);» returned correctly category-link, it is standart WordPress-category).

    https://wordpress.org/plugins/custom-post-type-ui/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Valentin E

    (@valentin-e)

    Code of this taxonomy (“services__types”):

    {"services__types":{"name":"services__types","label":"\u0422\u0438\u043f\u044b \u0423\u0441\u043b\u0443\u0433","singular_label":"\u0422\u0438\u043f \u0423\u0441\u043b\u0443\u0433\u0438","hierarchical":"true","show_ui":"true","query_var":"true","query_var_slug":"","rewrite":"true","rewrite_slug":"","rewrite_withfront":"1","rewrite_hierarchical":"0","show_admin_column":"false","labels":{"all_items":"\u0412\u0441\u0435 \u0442\u0438\u043f\u044b \u0423\u0441\u043b\u0443\u0433","add_new_item":"\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u0438\u043f \u0423\u0441\u043b\u0443\u0433\u0438","menu_name":"","edit_item":"","view_item":"","update_item":"","new_item_name":"","parent_item":"","parent_item_colon":"","search_items":"","popular_items":"","separate_items_with_commas":"","add_or_remove_items":"","choose_from_most_used":"","not_found":""},"object_types":["service"]}}

    and this post type (“service”):

    {"review":{"name":"review","label":"\u041e\u0442\u0437\u044b\u0432\u044b","singular_label":"\u041e\u0442\u0437\u044b\u0432","description":"","public":"true","show_ui":"true","has_archive":"false","has_archive_string":"","exclude_from_search":"false","capability_type":"post","hierarchical":"false","rewrite":"true","rewrite_slug":"","rewrite_withfront":"true","query_var":"true","menu_position":"","show_in_menu":"true","show_in_menu_string":"","menu_icon":null,"supports":["title","thumbnail"],"taxonomies":[],"labels":{"all_items":"\u0412\u0441\u0435 \u041e\u0442\u0437\u044b\u0432\u044b","add_new":"\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u041e\u0442\u0437\u044b\u0432","add_new_item":"\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u041e\u0442\u0437\u044b\u0432\u0430","edit":"\u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u041e\u0442\u0437\u044b\u0432","menu_name":"","edit_item":"","new_item":"","view":"","view_item":"","search_items":"","not_found":"","not_found_in_trash":"","parent":""}},"direction-service":{"name":"direction-service","label":"\u041d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0443\u0441\u043b\u0443\u0433","singular_label":"\u041d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0443\u0441\u043b\u0443\u0433","description":"","public":"true","show_ui":"true","has_archive":"false","has_archive_string":"","exclude_from_search":"false","capability_type":"post","hierarchical":"false","rewrite":"true","rewrite_slug":"","rewrite_withfront":"true","query_var":"true","menu_position":"","show_in_menu":"true","show_in_menu_string":"","menu_icon":null,"supports":["title"],"taxonomies":[],"labels":{"all_items":"\u0412\u0441\u0435 \u041d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0443\u0441\u043b\u0443\u0433","add_new":"\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u041d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0443\u0441\u043b\u0443\u0433","add_new_item":"\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u041d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0443\u0441\u043b\u0443\u0433","menu_name":"","edit":"","edit_item":"","new_item":"","view":"","view_item":"","search_items":"","not_found":"","not_found_in_trash":"","parent":""}},"service":{"name":"service","label":"\u0423\u0441\u043b\u0443\u0433\u0438","singular_label":"\u0423\u0441\u043b\u0443\u0433\u0430","description":"","public":"true","show_ui":"true","has_archive":"false","has_archive_string":"","exclude_from_search":"false","capability_type":"post","hierarchical":"false","rewrite":"true","rewrite_slug":"","rewrite_withfront":"true","query_var":"true","menu_position":"","show_in_menu":"true","show_in_menu_string":"","menu_icon":"","supports":["title"],"taxonomies":["services__types"],"labels":{"all_items":"\u0412\u0441\u0435 \u0423\u0441\u043b\u0443\u0433\u0438","add_new":"\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0423\u0441\u043b\u0443\u0433\u0443","add_new_item":"\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0439 \u0423\u0441\u043b\u0443\u0433\u0438","menu_name":"","edit":"","edit_item":"","new_item":"","view":"","view_item":"","search_items":"","not_found":"","not_found_in_trash":"","parent":""},"custom_supports":""}}

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Since you’re using a custom taxonomy, functions with “category” aren’t going to work because they’re intended for the actual category taxonomy that WordPress has out of box. I’d check out get_term_link() instead. http://codex.wordpress.org/Function_Reference/get_term_link. Same thing with template hierarchy, you shouldn’t be trying to use “category” in the template files for your custom taxonomy. https://developer.wordpress.org/files/2014/10/wp-template-hierarchy.jpg

    Thread Starter Valentin E

    (@valentin-e)

    It means that template archive{post_type}.php will not run to display category of user-taxonomy, even using get_term_link() function?
    Do I understand?

    If so, what name should be used for display category of user-taxonomy?
    (taxonomy-$taxonomy.php, taxonomy-$taxonomy-term.php or other )?

    Is it possible?

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    taxonomy-$taxonomy.php would be used for any term archive in $taxonomy. In your case, taxonomy-services__types.php. taxonomy-$taxonomy-$term.php is so that you can customize on a per-term level.

    If you had a service__types term of “auto”, then get_term_link() should, if I am recalling right, create a link to domain.com/service__type/auto/ and use, in order of availability, taxonomy-services__types-auto.php, taxonomy-services__types.php, taxonomy.php, and archive.php for the template file.

    Thread Starter Valentin E

    (@valentin-e)

    Thank you for helping to understand.
    It works the way I need!

    My confusion was that I perceived cetegories of user-taxonomy like original wordpress categories.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Glad I could help.

    Yeah, “category” and “post_tag” are technically two taxonomies that WP has done since forever. The difference, if you’re making your own and you want your own to behave like one or the other is based on the hierarchical setting. To make it category-like, you set hierarchical to true, and to behave more like tags, you set it to false. I think most of the category/tag based functions hardcode the taxonomy setting for you, but make use of similar functions available where you can set your own taxonomy value.

    I hope I’m not re-confusing here 🙂

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Can not link to category (user taxonomy), and not defined templates’ is closed to new replies.