WP_Links_List_Table::column_categories() WordPress Method

The WP_Links_List_Table::column_categories() method is used to generate the categories column in the link list table. This column is used to show the categories to which the link belongs. The method uses the get_the_term_list() function to retrieve the list of categories for the link.

WP_Links_List_Table::column_categories( object $link ) #

Handles the link categories column output.


Parameters

$link

(object)(Required)The current link object.


Top ↑

Source

File: wp-admin/includes/class-wp-links-list-table.php

	public function column_categories( $link ) {
		global $cat_id;

		$cat_names = array();
		foreach ( $link->link_category as $category ) {
			$cat = get_term( $category, 'link_category', OBJECT, 'display' );
			if ( is_wp_error( $cat ) ) {
				echo $cat->get_error_message();
			}
			$cat_name = $cat->name;
			if ( (int) $cat_id !== $category ) {
				$cat_name = "<a href='link-manager.php?cat_id=$category'>$cat_name</a>";
			}
			$cat_names[] = $cat_name;
		}
		echo implode( ', ', $cat_names );
	}


Top ↑

Changelog

Changelog
VersionDescription
4.3.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.