Using WordPress ‘link_categories_meta_box()’ PHP function

The link_categories_meta_box() WordPress PHP function displays link categories form fields.

Usage

link_categories_meta_box( $link );

Example:

Input:

$link = get_link( 5 );
link_categories_meta_box( $link );

Output:
Displays the link categories form fields for the link with ID 5.

Parameters

  • $link (object) – Required. The current link object.

More information

See WordPress Developer Resources: link_categories_meta_box

This function is primarily used in the WordPress admin area for managing links and their categories.

Examples

This example retrieves a link with the ID 10 and displays its link categories form fields.

$link = get_link( 10 );
link_categories_meta_box( $link );

This example retrieves an array of links and displays the link categories form fields for the first link in the array.

$links = get_links( array( 'limit' => 5 ) );
$link = $links[0];
link_categories_meta_box( $link );

This example finds a link with the specified URL and displays its link categories form fields.

$link_url = 'https://www.example.com';
$links = get_links( array( 'search' => $link_url ) );
$link = $links[0];
link_categories_meta_box( $link );

This example retrieves a link in a specific category and displays its link categories form fields.

$links = get_links( array( 'category' => 3 ) );
$link = $links[0];
link_categories_meta_box( $link );

This example finds a link with the specified name and displays its link categories form fields.

$link_name = 'My Example Link';
$links = get_links( array( 'search' => $link_name ) );
$link = $links[0];
link_categories_meta_box( $link );