Structured list of tags
-
I have appointed “Att. Category” for photos using children level categories.
Like:- Category 1
- Category 1.1
- Category 1.2
- …
- Category 1.n
- Category 2
- Category 2.1
- Category 2.2
- Category 2.2.1
- Category 2.2.2
- …
- Category 2.2.n
- …
- Category 2.n
For example: http://joxi.ru/l2ZvRRKiEo582J.png
How can I display a tag cloud in the form of a structured list?
-
Good to hear from you again, and thanks for your question. Thanks as well for your patience while I was travelling.
The current MLA version has the
[mla_tag_cloud]
shortcode, but does not have any specific support for showing a hierarchical taxonomy as a structured list. I did some preliminary research on adding this feature but have not started development. The WordPress core team has a project which will change the way WordPress itself supports these features and I am waiting to see what they do.If you are willing to do a bit of PHP programming you can accomplish your goal. You can find more information on this approach in an earlier support topic:
How to display pad_counts for hierarchical taxonomies
If you need more specific help with the coding for the PHP solution, update this topic and I will give you what help I can. I will leave the topic unresolved for now and update it when I have made progress on adding something like this to a future MLA version.
thank you, I’ll read a topic 🙂
I did as it is written in the topic:
insert into the template this code:
/** * Class MNA_Pad_Counts_Walker adds accurate, padded attachment counts to taxonomy terms. * * Class Walker is defined in /wp-includes/class-wp-walker.php * Class Walker_Category is defined in /wp-includes/category-template.php */ class MNA_Pad_Counts_Walker extends Walker_Category { /** * MLA Terms * * @var array */ public $mla_terms = array(); /** * Constructor - set the MLA Terms. * * @param string Taxonomy name/slug. */ function __construct( $taxonomy ) { $attr = array ( 'taxonomy' => $taxonomy, 'pad_counts' => 'true', ); $terms = MLAShortcodes::mla_get_terms( $attr ); unset( $terms['found_rows'] ); foreach ( $terms as $term ) { $this->mla_terms[ $term->term_taxonomy_id ] = $term->count; } } /** * Start the element output. * * @see Walker::start_el() * * @param string Passed by reference. Used to append additional content. * @param object Taxonomy data object. * @param int Depth of category in reference to parents. Default 0. * @param array An array of arguments. @see wp_list_categories() * @param int ID of the current category. */ function start_el( &$output, $taxonomy_object, $depth = 0, $args = array(), $id = 0 ) { if ( isset( $this->mla_terms[ $taxonomy_object->term_taxonomy_id ] ) ) { $taxonomy_object->count = $this->mla_terms[ $taxonomy_object->term_taxonomy_id ]; } parent::start_el( $output, $taxonomy_object, $depth, $args, $id ); } }// Class MNA_Pad_Counts_Walker
insert in /wp-includes/category-template.php this code:
foreach ($taxonomies as $taxonomy) { unset( $checklist_walker ); $checklist_walker = new MNA_Pad_Counts_Walker( $taxonomy ); $args = array( 'taxonomy' => $taxonomy, 'hierarchical' => 1, 'hide_empty' => 0, 'pad_counts' => 1, 'show_count' => 1, 'title_li' => '', 'walker' => $checklist_walker, ); echo '<li id="c' . $taxonomy . '" class="tax_list">' . get_taxonomy( $taxonomy )->label . '<ul>'; wp_list_categories( $args ); echo '</ul></li>'; }
after this code:
function wp_list_categories( $args = '' ) { $defaults = array( 'show_option_all' => '', 'show_option_none' => __('No categories'), 'orderby' => 'name', 'order' => 'ASC', 'style' => 'list', 'show_count' => 0, 'hide_empty' => 1, 'use_desc_for_title' => 1, 'child_of' => 0, 'feed' => '', 'feed_type' => '', 'feed_image' => '', 'exclude' => '', 'exclude_tree' => '', 'current_category' => 0, 'hierarchical' => true, 'title_li' => __( 'Categories' ), 'echo' => 1, 'depth' => 0, 'taxonomy' => 'category' );
But there is no result.
What did i do wrong?Thank you for taking the time to read through the earlier topic and adapting your templates along the lines it suggested. It is hard to tell why you get no results from just the fragments of code you have posted above. If you send me your contact information I can give you an e-mail address you can use to send a copy of the complete template. You can use the Contact Us page at the FTJ web site:
Once I see all of the code I will try to work with you to make it work. Thanks for your understanding and your patience.
Thank you for the update you posted in your related topic:
Based on the information in that post I am marking this topic resolved. I will continue working with you on the issues identified in the “MLA + WPML” topic.
- The topic ‘Structured list of tags’ is closed to new replies.