How to draw a subcategory link? A subcategory is a child of the main category. For some reason, I display both the main and subsidiary in the list. Is it possible to display the last nesting category, and not the entire canvas. Those. there is новости > мировые > пост . On the post page, display a link to the мировые category.
- It is worthwhile to show / tell in more detail about "the main and subsidiary is displayed in the list." What is the list, how / what is done? Where is displayed. Show the code if it is a code. This can be done by editing the question. - SeVlad
- @SeVlad For example, I am on the post page, the post in my turn is in the world heading and the world heading is in the news heading, I need to make a link to the world heading in the body of the post. Those last column in which the post lies. - Anton Essential
|
1 answer
the_category () Displays links to categories to which the post belongs. Must be inside a Wordpress loop.
Post category output: <?php the_category(); ?> <?php the_category(); ?> output the мировые with a link, if the post does NOT belong to the category of новости , but only its subsidiary is the мировые .
- Thank you fit, can I somehow set the class? it turns out that the function displays a link without a class - Anton Essential
- Is this way ok? function add_class_the_category ($ html) {$ postid = get_the_ID (); $ html = str_replace ('<a', '<a class = "single__article__top__link"', $ html); return $ html; } add_filter ('the_category', 'add_class_the_category'); - Anton Essential
- and not a beard, if the news is in two headings is displayed under the heading. - Anton Essential
- Well, as it is natural that if in two, then both will lead. And if at 10, then all 10. To whom it belongs, it will bring it out. - SeVlad
- oneWell, at least thanks and on this! - Anton Essential
|