/ Published in: PHP
Add this snippet to the functions.php of your wordpress theme. This will add a select menu with an automatically generated list of your shortcodes for your pages and posts.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// shortcode button add_action('media_buttons','add_sc_select',11); function add_sc_select(){ global $shortcode_tags; /* ------------------------------------- */ /* enter names of shortcode to exclude bellow */ /* ------------------------------------- */ echo ' <select id="sc_select"><option>Shortcode</option>'; foreach ($shortcode_tags as $key => $val){ $shortcodes_list .= '<option value="['.$key.'][/'.$key.']">'.$key.'</option>'; } } echo $shortcodes_list; echo '</select>'; } add_action('admin_head', 'button_js'); function button_js() { echo '<script type="text/javascript"> jQuery(document).ready(function(){ jQuery("#sc_select").change(function() { send_to_editor(jQuery("#sc_select :selected").val()); return false; }); }); </script>'; }