Support » Plugins » Hacks » How to insert data into post area?

  • Resolved Canha


    Hey guys, I have a question.

    I’m creating a plugin that shows a custom box in a custom post type area. When the user inserts data into an input inside this custom box, the plugin uses this value to return another one.

    How can I automatically copy this input into the post area? (Where the post is written). I’ve considered just telling the user to CTRL+C, CTRL+V in the post area. But there has to be another way. I thought of Javascript, but I want to know if there is any other way to do this.


Viewing 3 replies - 1 through 3 (of 3 total)
  • juliovedovatto


    Try this (javascript):

    window.send_to_editor(‘VALUE THAT U WANT’);
    window.location.hash = ‘postdivrich’;

    I respond to you here, because in twitter you never see what I send to you LOL



    Thanks! Sorry, didn’t see you reply on Twitter (keep getting lots of those).

    I ended up using javascript in a different way, as I couldn’t find a non-JS solution:
    document.getElementById("content").value = "<?php echo $myVar; ?>";

    as #content is the ID for the textarea.

    I’m leaving this here for anyone who might have this trouble:
    It’s easier to use Javascript (or jQuery) to insert data into the post textarea. If you must insert the data without cleaning up the textarea, do the following:

    var whatIsAlreadyThere = document.getElementById("content").value;
    var whatYouWantToAdd = "Whatever you want to add";
    document.getElementById("content").value = whatIsAlreadyThere + whatYouWantToAdd

    You may want to add some kind of space in the second var.

    Leo Blanchette



    two months later…had to express thanks! You solved my problem in two lines of code. Thanks a lot!!!!!!!

    Original thread…

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to insert data into post area?’ is closed to new replies.