Random WordPress Function

Learn about a new WordPress function every day!


Function Signature:

link_xfn_meta_box

Function Description:

Displays XFN form fields.

Function Examples:

⚠️ Examples below are generated with GPT-3 once every hour. Do not take them too seriously.
Consider them as some extra input in your learning process - reason about them. Will it work? What could fail?
// Example 1: Adding the link_xfn_meta_box to a custom post type
add_action( 'add_meta_boxes', 'custom_post_type_xfn_meta_box' );
function custom_post_type_xfn_meta_box() {
    add_meta_box( 'xfn_meta_box', 'XFN', 'link_xfn_meta_box', 'custom_post_type', 'normal', 'high' );
}
// Example 2: Displaying the XFN meta box only for specific user roles
add_action( 'add_meta_boxes', 'restrict_xfn_meta_box' );
function restrict_xfn_meta_box() {
    if ( current_user_can( 'editor' ) || current_user_can( 'administrator' ) ) {
        add_meta_box( 'xfn_meta_box', 'XFN', 'link_xfn_meta_box', 'post', 'normal', 'high' );
    }
}
// Example 3: Removing the XFN meta box from the default post type
add_action( 'add_meta_boxes', 'remove_xfn_meta_box' );
function remove_xfn_meta_box() {
    remove_meta_box( 'xfn_meta_box', 'post', 'normal' );
}