Using WordPress ‘get_the_author_aim()’ PHP function

The get_the_author_aim() WordPress PHP function retrieves the AIM address of the author of the current post.

Usage

$author_aim = get_the_author_aim();

Parameters

  • None

More information

See WordPress Developer Resources: get_the_author_aim()

Examples

Display author AIM in a post

In this example, we display the author’s AIM address within a post template.

// Get the author's AIM address
$author_aim = get_the_author_aim();

// Display the author's AIM address
echo 'Author AIM: ' . $author_aim;

Add author AIM to post metadata

In this example, we add the author’s AIM address to the post metadata section.

// Get the author's AIM address
$author_aim = get_the_author_aim();

// Check if the author has an AIM address
if (!empty($author_aim)) {
    echo '<div class="post-meta">';
    echo 'Author AIM: ' . $author_aim;
    echo '</div>';
}

Create a function to retrieve the author AIM

In this example, we create a function to easily retrieve the author AIM in any part of our theme.

function display_author_aim() {
    // Get the author's AIM address
    $author_aim = get_the_author_aim();

    // Display the author's AIM address
    echo 'Author AIM: ' . $author_aim;
}

Show author AIM only if exists

In this example, we only display the author’s AIM address if it exists.

// Get the author's AIM address
$author_aim = get_the_author_aim();

// Display the author's AIM address if it exists
if (!empty($author_aim)) {
    echo 'Author AIM: ' . $author_aim;
}

Add author AIM to author bio

In this example, we add the author’s AIM address to their bio section.

// Get the author's AIM address
$author_aim = get_the_author_aim();

// Display the author's bio and AIM address
echo '<div class="author-bio">';
echo 'Author Bio: ' . get_the_author_meta('description');
if (!empty($author_aim)) {
    echo '<br>Author AIM: ' . $author_aim;
}
echo '</div>';