Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have created pop up tiny mce window.But this is not inserting the value when i click create shortcode.

<!DOCTYPE html>
<title>Create Gallery Shortcode</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

<script type="text/javascript" src="../../../../../../wp-includes/js/tinymce/tiny_mce_popup.js"></script>
<script type="text/javascript">
    var GalleryTiny = {
e: '',
init: function(e) {
    GalleryTiny.e = e;
insert: function createGalleryShortcode(e) {
    //Create gallery Shortcode
    var postID = $('#GalleryPostID').val();
    var columns = $('#GalleryColumns').val();
    var size = $('#GallerySize').val();

    if(size == '') {
        size = 'thumbnail';

    var output ='[gallery';
    if(postID) {
        output += 'id="'+postID+'" ';
    if(columns) {
        output += 'columns="'+columns+'" ';
    if(size) {
        output += 'size="'+size+'" ';

    output += ']';

    tinyMCEPopup.execCommand('mceReplaceContent', false, output);


tinyMCEPopup.onInit.add(GalleryTiny.init, GalleryTiny);
<form id="GalleryShortcode">
        <label for="GalleryPostID">Post ID (Leave blank for current post):</label><br/>
        <input id="GalleryPostID" type="text" value="" />
        <label for="GalleryColumns">Number of Columns:</label><br/>
        <input id="GalleryColumns" type="text" value="" />
        <label for="GallerySize">Thumbnail Size (Leave blank for thumbnail):</label><br/>
        <input id="GallerySize" type="text" value="" />
    <p><a href="javascript:GalleryTiny.insert(GalleryTiny.e)">Create Shortcode</a></p>

share|improve this question
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.