Walker_Category
- Since
- 2.1.0
- Source
wp-includes/class-walker-category.php:17
Core class used to create an HTML list of categories.
Hooks fired · 4
Every hook that fires from inside Walker_Category, in the order it appears in the class, grouped by the method that fires it.
Walker_Category::start_el()
- apply_filters( list_cats )filter line 106
- apply_filters( category_description )filter line 125
- apply_filters( category_list_link_attributes )filter line 144
- apply_filters( category_css_class )filter line 245
Properties · 2
$tree_typestringpublic- What the class handles.
$db_fieldsstring[]public- Database fields to use.
Methods · 4
- start_lvl()Starts the list before the elements are added.
- end_lvl()Ends the list of after the elements are added.
- start_el()Starts the element output.
- end_el()Ends the element output, if needed.
Source
class Walker_Category extends Walker { /** * What the class handles. * * @since 2.1.0 * @var string * * @see Walker::$tree_type */ public $tree_type = 'category'; /** * Database fields to use. * * @since 2.1.0 * @var string[] * * @see Walker::$db_fields * @todo Decouple this */ public $db_fields = array( 'parent' => 'parent', 'id' => 'term_id', ); /** * Starts the list before the elements are added. * * @since 2.1.0 * * @see Walker::start_lvl() * * @param string $output Used to append additional content. Passed by reference. * @param int $depth Optional. Depth of category. Used for tab indentation. Default 0. * @param array $args Optional. An array of arguments. Will only append content if style argument * value is 'list'. See wp_list_categories(). Default empty array. */ public function start_lvl( &$output, $depth = 0, $args = array() ) { if ( 'list' !== $args['style'] ) { return; } $indent = str_repeat( "\t", $depth ); $output .= "$indent<ul class='children'>\n"; } /** * Ends the list of after the elements are added. * * @since 2.1.0 * * @see Walker::end_lvl() * * @param string $output Used to append additional content. Passed by reference. * @param int $depth Optional. Depth of category. Used for tab indentation. Default 0. * @param array $args Optional. An array of arguments. Will only append content if style argument * value is 'list'. See wp_list_categories(). Default empty array. */ public function end_lvl( &$output, $depth = 0, $args = array() ) { if ( 'list' !== $args['style'] ) { return; } $indent = str_repeat( "\t", $depth ); $output .= "$indent</ul>\n"; } /** * Starts the element output. * * @since 2.1.0 * @since 5.9.0 Renamed `$category` to `$data_object` and `$id` to `$current_object_id` * to match parent class for PHP 8 named parameter support. * * @see Walker::start_el() * * @param string $output Used to append additional content (passed by reference). * @param WP_Term $data_object Category data object. * @param int $depth Optional. Depth of category in reference to parents. Default 0.History
Introduced in 2.1.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.8.8 tag, from
src/wp-includes/class-walker-category.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.