Discover in this tutorial how to display all the information you are interested in from any plugin in the WordPress repository using the API.
In a previous tutorial you saw how to get all the plugins created by a WordPress user.
In this case, you are going to use the dedicated API to get all the associated data you are interested in (name, ratings, active installations, version, description…) for a WordPress plugin and display them as you want.
This would be the final result:
Shall we start?
Steps to display plugin information from the WordPress repository
1. Create a shortcode with the repository plugin attribute
Add the following code at the end of functions.php or in your functionality plugin:
To see this and another 1097 code snippets of this website, login or subscribe here.
With the above code you create a shortcode with the slug
attribute that allows you to indicate the slug of the plugin from the WordPress repository. Once the plugin is defined, you query the plugin API to extract the data you are interested in.
In this example you “paint” the following data:
- Plugin name (with link).
- Rating (indicated with number of stars).
- Number of ratings.
- Plugin version.
- WordPress version on which it is tested.
- Minimum WordPress version required.
- Description.
- Download button.
Obviously, you can modify what you see fit to display the data you consider convenient.
In the example you are only getting the data of 10 endpoints but with the API, when you make the request for information about a plugin, you can access all of these:
name
slug
version
author
author_profile
contributors
requires
tested
requires_php
requires_plugins
rating
ratings
num_ratings
support_threads
support_threads_resolved
active_installs
downloaded
last_updated
added
homepage
sections
description
installation
faq
screenshots
changelog
reviews
download link
screenshots
tags
versions
donate_link
- banners
preview_link
If you have doubts about the slug of a plugin you can visit its page in the WordPress repository. The URL will be: https://wordpress.org/plugins/plugin-slug.
2. Customize how the plugin information is displayed
In the code above you not only have all the functional part but you also add CSS classes to the different data you display. This allows you to modify the appearance of each of them to suit your needs.
3. Insert the shortcode where you want
Finally, just type[plugins_info slug="osom-modal-login"]
where you want it to be displayed and change the plugin slug
to the one you want.
This would be an example of the listing that would show the shortcode if you put slug="osom-modal-login"
of WordPress:
Conclusions
Now you know how to display the information you are interested in from any plugin in the WordPress repository using its API.
Any questions? I read you in the comments.
And if you want to give me any suggestion for future tutorials, leave it in the contact form. Advantages of being a subscriber. 😉