Title: wp_get_link_cats
Published: April 25, 2014
Last modified: May 20, 2026

---

# wp_get_link_cats( int $link_id ): int[]

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/wp_get_link_cats/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_get_link_cats/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_get_link_cats/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_get_link_cats/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_get_link_cats/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_get_link_cats/?output_format=md#wp--skip-link--target)

Retrieves the link category IDs associated with the link specified.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_get_link_cats/?output_format=md#parameters)󠁿

 `$link_id`intrequired

Link ID to look up.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_get_link_cats/?output_format=md#return)󠁿

 int[] The IDs of the requested link’s categories.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_get_link_cats/?output_format=md#source)󠁿

    ```php
    function wp_get_link_cats( $link_id = 0 ) {
    	$cats = wp_get_object_terms( $link_id, 'link_category', array( 'fields' => 'ids' ) );
    	return array_unique( $cats );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/bookmark.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-admin/includes/bookmark.php#L126)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-admin/includes/bookmark.php#L126-L129)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_get_link_cats/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_get_object_terms()](https://developer.wordpress.org/reference/functions/wp_get_object_terms/)`wp-includes/taxonomy.php` |

Retrieves the terms associated with the given object(s), in the supplied taxonomies.

  |

| Used by | Description | 
| [WP_Links_List_Table::display_rows()](https://developer.wordpress.org/reference/classes/wp_links_list_table/display_rows/)`wp-admin/includes/class-wp-links-list-table.php` |

Generates the list table rows.

  | 
| [wp_link_category_checklist()](https://developer.wordpress.org/reference/functions/wp_link_category_checklist/)`wp-admin/includes/template.php` |

Outputs a link category checklist element.

  | 
| [get_linkcatname()](https://developer.wordpress.org/reference/functions/get_linkcatname/)`wp-includes/deprecated.php` |

Gets the name of category by ID.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_get_link_cats/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.1.0](https://developer.wordpress.org/reference/since/2.1.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_get_link_cats%2F)
before being able to contribute a note or feedback.