Using WordPress ‘get_the_author_yim()’ PHP function

The get_the_author_yim() WordPress PHP function retrieves the Yahoo! IM name of the author of the current post.

Usage

echo get_the_author_yim();

Parameters

  • None

More information

See WordPress Developer Resources: get_the_author_yim

Examples

Display Author’s Yahoo! IM Name in a Post

To display the author’s Yahoo! IM name in a post, you can use the following code within the WordPress loop:

if ( have_posts() ) {
    while ( have_posts() ) {
        the_post();
        echo 'Author Yahoo! IM: ' . get_the_author_yim();
    }
}

Add Author’s Yahoo! IM Name to Post Meta

You can add the author’s Yahoo! IM name to the post meta using the following code:

function display_author_yim() {
    $yim = get_the_author_yim();
    echo '<span class="author-yim">Yahoo! IM: ' . $yim . '</span>';
}
add_action( 'genesis_entry_header', 'display_author_yim' );

Show Author’s Yahoo! IM Name Only if Available

To only display the author’s Yahoo! IM name if it’s available, use the following code:

$yim = get_the_author_yim();
if ( !empty( $yim ) ) {
    echo 'Author Yahoo! IM: ' . $yim;
}

Display Yahoo! IM Name in Author Archive Page

To display the Yahoo! IM name of an author in their archive page, use the following code:

if ( is_author() ) {
    echo 'Author Yahoo! IM: ' . get_the_author_yim();
}

Create a Custom Function to Display Author’s Yahoo! IM Name

You can create a custom function to display the author’s Yahoo! IM name and use it in your theme:

function custom_author_yim() {
    $yim = get_the_author_yim();
    echo '<div class="author-yim">Author Yahoo! IM: ' . $yim . '</div>';
}
add_action( 'custom_author_info', 'custom_author_yim' );

Then, you can call this custom action in your theme:

do_action( 'custom_author_info' );