Using WordPress ‘get_the_author_icq()’ PHP function

The get_the_author_icq() WordPress PHP function retrieves the ICQ number of the author of the current post.

Usage

get_the_author_icq();

Example:

Input:

echo get_the_author_icq();

Output:

123456789

Parameters

  • None

More information

See WordPress Developer Resources: get_the_author_icq()

Examples

Display the ICQ number in the author box

This example shows how to display the author’s ICQ number in an author box below the post content.

<div class="author-box">
  <h3>Author: <strong><?php the_author(); ?></strong></h3>
  <!-- Display the ICQ number if it exists -->
  <?php if (get_the_author_icq()) : ?>
    <p>ICQ: <strong><?php echo get_the_author_icq(); ?></strong></p>
  <?php endif; ?>
</div>

Add the ICQ number to the author’s bio

In this example, the author’s ICQ number is added to the author’s bio.

function add_icq_to_author_bio($bio) {
  $icq = get_the_author_icq();
  if ($icq) {
    $bio .= ' ICQ: <strong>' . $icq . '</strong>.';
  }
  return $bio;
}
add_filter('get_the_author_description', 'add_icq_to_author_bio');

Add the ICQ number to author’s info in a widget

This example demonstrates adding the author’s ICQ number to an author’s info in a custom widget.

class Author_ICQ_Widget extends WP_Widget {
  function __construct() {
    parent::__construct(
      'author_icq_widget',
      'Author ICQ',
      array('description' => 'Displays the author\'s ICQ number')
    );
  }

  public function widget($args, $instance) {
    echo $args['before_widget'];
    if (!empty($instance['title'])) {
      echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
    }
    echo 'ICQ: <strong>' . get_the_author_icq() . '</strong>';
    echo $args['after_widget'];
  }
}
add_action('widgets_init', function(){ register_widget('Author_ICQ_Widget'); });

Display the ICQ number in the author’s archive page

This example shows how to display the author’s ICQ number on the author’s archive page.

// In author.php or archive.php
if (is_author()) {
  $icq = get_the_author_icq();
  if ($icq) {
    echo '<p>ICQ: <strong>' . $icq . '</strong></p>';
  }
}

Display the ICQ number with a custom label

In this example, the author’s ICQ number is displayed with a custom label.

<?php if (get_the_author_icq()) : ?>
  <p>My ICQ: <strong><?php echo get_the_author_icq(); ?></strong></p>
<?php endif; ?>