Select Page

Notice: A non well formed numeric value encountered in /srv/www/public_html/atif.rocks/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118

Notice: A non well formed numeric value encountered in /srv/www/public_html/atif.rocks/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119

Notice: A non well formed numeric value encountered in /srv/www/public_html/atif.rocks/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118

Notice: A non well formed numeric value encountered in /srv/www/public_html/atif.rocks/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119

Notice: A non well formed numeric value encountered in /srv/www/public_html/atif.rocks/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118

Notice: A non well formed numeric value encountered in /srv/www/public_html/atif.rocks/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119

I knew how to create and use the Shortcodes in WordPress. But my client wanted to automate the creation and insertion of the Shortcode – into the posts and pages. I tried googling but didnt find any tutorial on how to create the Buttons above the editor, like the Add Media Button. So I looked into some plugins that were using the Media Buttons, and figured out how to create them.

To start off, you need to create the Media Button by using the WordPress hook “media_buttons_context”.

Now create the hooked function to configure the button.

Now we create a function to add the contents to the popup box. This popup will show up when our Media Button is clicked. We are going to hook this function to the wordpress footer, using the “admin_footer” hook, so it loads in the footer when admin page is loaded.

End Result: Notice our “CanonRedi” media button.media-button