Filter hook 'category_list_link_attributes'

in WP Core File wp-includes/class-walker-category.php at line 144

View Source

category_list_link_attributes

Filter Hook
Description
Filters the HTML attributes applied to a category list item's anchor element. }

Hook Information

File Location wp-includes/class-walker-category.php View on GitHub
Hook Type Filter
Line Number 144

Hook Parameters

Type Name Description
array $atts { The HTML attributes applied to the list item's `` element, empty strings are ignored.
WP_Term $category Term data object.
int $depth Depth of category, used for padding.
array $args An array of arguments.
int $current_object_id ID of the current category.

Usage Examples

Basic Usage
<?php
// Hook into category_list_link_attributes
add_filter('category_list_link_attributes', 'my_custom_filter', 10, 5);

function my_custom_filter($atts, $category, $depth, $args, $current_object_id) {
    // Your custom filtering logic here
    return $atts;
}

Source Code Context

wp-includes/class-walker-category.php:144 - How this hook is used in WordPress core
<?php
 139  		 * @param WP_Term $category          Term data object.
 140  		 * @param int     $depth             Depth of category, used for padding.
 141  		 * @param array   $args              An array of arguments.
 142  		 * @param int     $current_object_id ID of the current category.
 143  		 */
 144  		$atts = apply_filters( 'category_list_link_attributes', $atts, $category, $depth, $args, $current_object_id );
 145  
 146  		$attributes = '';
 147  		foreach ( $atts as $attr => $value ) {
 148  			if ( is_scalar( $value ) && '' !== $value && false !== $value ) {
 149  				$value       = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );

PHP Documentation

<?php
/**
		 * Filters the HTML attributes applied to a category list item's anchor element.
		 *
		 * @since 5.2.0
		 *
		 * @param array   $atts {
		 *     The HTML attributes applied to the list item's `<a>` element, empty strings are ignored.
		 *
		 *     @type string $href  The href attribute.
		 *     @type string $title The title attribute.
		 * }
		 * @param WP_Term $category          Term data object.
		 * @param int     $depth             Depth of category, used for padding.
		 * @param array   $args              An array of arguments.
		 * @param int     $current_object_id ID of the current category.
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 5
  • File: wp-includes/class-walker-category.php
Related Hooks

Related hooks will be displayed here in future updates.