Source Code


Shortcode Plugin Template for WordPress

By: Maximilian Brandmaier


This project serves as a template for a WordPress shortcode plugin. It shows how to integrate PHP, JS, CSS and database access into a shortcode.


Place the folder "shortcode-plugin-template" into the "plugins" folder of your WordPress installation. It is usually located at "/wp-content/plugins". The plugin will show up on your WordPress website where you can activate it in the plugin overview.


After installing the plugin, you can use the following shortcode in any article or page of your WordPress blog. It will display a code example in the form of a simple counter that can be increased and decreased.



It is intended that you change the code example to your own code. Make sure to

  • Change the plugin and shortcode name by renaming the folder and adapting "shortcode-plugin-template.php"
  • Write your own activation and uninstall functions in "shortcode-plugin-template.php" and "uninstall.php"
  • Add your PHP and HTML code in "components/main.php"
  • Add your CSS in "styles/main.css"
  • Add your JS in "scripts/main.js"

This template only contains a minimal setup, feel free to register more files and functions in "shortcode-plugin-template.php" in order to build a more complex plugin architecture.