On this page
wp_set_link_cats( int $link_id, int[] $link_categories = array() )
Update link with the specified link categories.
Parameters
$link_idint Required-
ID of the link to update.
$link_categoriesint[] Optional-
Array of link category IDs to add the link to.
Default:
array()
Source
File: wp-admin/includes/bookmark.php. View all references
function wp_set_link_cats( $link_id = 0, $link_categories = array() ) {
// If $link_categories isn't already an array, make it one:
if ( ! is_array( $link_categories ) || 0 === count( $link_categories ) ) {
$link_categories = array( get_option( 'default_link_category' ) );
}
$link_categories = array_map( 'intval', $link_categories );
$link_categories = array_unique( $link_categories );
wp_set_object_terms( $link_id, $link_categories, 'link_category' );
clean_bookmark_cache( $link_id );
}
Related
Uses
| Uses | Description |
|---|---|
| wp_set_object_terms() wp-includes/taxonomy.php | Creates term and taxonomy relationships. |
| clean_bookmark_cache() wp-includes/bookmark.php | Deletes the bookmark cache. |
| get_option() wp-includes/option.php | Retrieves an option value based on an option name. |
Used By
| Used By | Description |
|---|---|
| wp_insert_link() wp-admin/includes/bookmark.php | Inserts a link into the database, or updates an existing link. |
Changelog
| Version | Description |
|---|---|
| 2.1.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_set_link_cats