Using WordPress ‘install_popular_tags()’ PHP function

The install_popular_tags() WordPress PHP function retrieves popular WordPress plugin tags.

Usage

install_popular_tags( $args );

Custom example:

$args = array( 'number' => 10 );
$popular_tags = install_popular_tags( $args );
echo implode(', ', $popular_tags);

Output:

e-commerce, gallery, seo, social, widgets, forms, security, analytics, slider, cache

Parameters

  • $args (array) – Optional. Default: array(). An array of arguments to filter the results.

More Information

See WordPress Developer Resources: install_popular_tags()

Examples

Get the top 5 popular plugin tags and display them as a comma-separated list.

$args = array( 'number' => 5 );
$popular_tags = install_popular_tags( $args );
echo implode(', ', $popular_tags);

Retrieve the popular plugin tags and display them as an unordered list in HTML.

$popular_tags = install_popular_tags();
echo '<ul>';
foreach ($popular_tags as $tag) {
    echo '<li>' . $tag . '</li>';
}
echo '</ul>';

Use a custom API URL to retrieve the popular tags.

$args = array( 'api_url' => 'https://custom-api-url.com' );
$popular_tags = install_popular_tags( $args );
echo implode(', ', $popular_tags);

Retrieve a custom number of popular plugin tags and display them as an ordered list in HTML.

$args = array( 'number' => 7 );
$popular_tags = install_popular_tags( $args );
echo '<ol>';
foreach ($popular_tags as $tag) {
    echo '<li>' . $tag . '</li>';
}
echo '</ol>';

Retrieve the popular plugin tags and display them as a dropdown menu in HTML.

$popular_tags = install_popular_tags();
echo '<select>';
foreach ($popular_tags as $tag) {
    echo '<option value="' . $tag . '">' . $tag . '</option>';
}
echo '</select>';