wp_set_link_cats()
Updates link with the specified link categories.
No Hooks.
Returns
null. Nothing (null).
Usage
wp_set_link_cats( $link_id, $link_categories );
- $link_id(int)
- ID of the link to update.
- $link_categories(int[])
- Array of link category IDs to add the link to.
Default:array()
Changelog
| Since 2.1.0 | Introduced. |
wp_set_link_cats() wp set link cats code WP 7.0
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 );
}