Support » Plugins » Hacks » Add ajax to new post page

  • Hello,

    I’m trying to add a simple ajax callback to my ‘new post’ page.

    When I create new posts, I have info that is easy for a server to fetch, but a hassle for me to type out. I’d like to be able to trigger the call, and fill my blank post up with the fetched text.

    This doesn’t sound easy, and so a fallback is for me to just print the text out somewhere on the page for me to copy paste to the new post. I could even write this as a separate plugin with it’s own page, but the fewer steps I can have between clicking the trigger and filling my post with the fetched text, the better.

    Work I’ve done so far:

    I’ve poured over the docs for adding ajax to an admin page. I’ve tried to add or include the various test calls straight to the edit-form-advanced page (no luck). I’ve tried adding simple text / javascript to the edit-form-advanced page (that works just fine). I seem unable to call a php callback from the new post page.

    Any help is welcome, including “Don’t do it that way. You’ll break wordpress”.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz


    Ajax calls from the editor would be difficult. I think you want to explore the Shortcode_API. You can pass the specifics as parameters to the shortcode, and then the shortcode handler can gather the details and echo them out in the post.

    The one thing that may be a problem here is the handler is called each time the post is viewed, the contents it produces is not stored in the post contents in the DB.

Viewing 1 replies (of 1 total)
  • The topic ‘Add ajax to new post page’ is closed to new replies.