As an example, my site is mysite.com
I want mysite.com/wordpress_plugins
to return the output of get_plugins()
from https://codex.wordpress.org/Function_Reference/get_plugins
How can I do this?
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communityAs an example, my site is mysite.com
I want mysite.com/wordpress_plugins
to return the output of get_plugins()
from https://codex.wordpress.org/Function_Reference/get_plugins
How can I do this?
The get_plugins() function will return an array of plugin. See https://codex.wordpress.org/Function_Reference/get_plugins . You can use that array of information to extract the info you want.
You could use that function in a shortcode, then put the shortcode on your page.
I note that there are plugins that purport to list plugins. In fact, some of those plugins will allow you to use a shortcode to list them.
So, it depends on whether you want to 'roll your own' or use a plugin. The information is out there (do a plugin search for 'list plugins').
You might also look at the answer to this question: What WordPress API function lists active/inactive plugins?
If you wanted to display a list of all of your plugins on your page, you could use a WordPress shortcode on your page as Rick above has suggested.
Some example code to show how to do this is below:
function list_my_plugins(){
$plugins = get_plugins();
$output = '<ul>';
foreach ( $plugins as $plugin ){
$output .= '<li>' . $plugin['Name'] . '</li>';
}
$output .= '</ul>';
return $output;
}
add_shortcode('list-my-plugins', 'list_my_plugins');
Simply add the above code to your functions.php file or create it as a plugin, then you'd just need to use the shortcode [list-my-plugins]
on your page.
You can see a full list of the plugin information that is available in the returned array on the codex page in the 'Example output': https://codex.wordpress.org/Function_Reference/get_plugins