Support » Plugins » Hacks » Querying the wpdb from within a custom tinyMCE button popup

  • I have a plugin that allows people to create content modules via custom fields. They can then use shortcodes to insert a specific content module within their posts/pages. To make it user friendly, I’ve created a tinyMCE button that pops up and gets settings from the user.

    I would like to be able to query the database from within this popup so that the content modules (custom post type) show in a dropdown menu and the user can select which one they want to show. For example, something like this:

    <select id="content_box_value" name="content_box_value">
        $boxes = array( 'post_type' => 'wp-content-box', 'numberposts' => -1);
        $post_box = get_posts($boxes;
        foreach( $post_box as $key ) : setup_postdata($key); ?>
        <option value="<? echo $key->ID; ?>" <?php selected($options, $key->ID); ?>><?php echo $key->post_title; ?></option>
        <?php endforeach; ?>

    Does anyone know of a simple way to accomplish this? I know its doable via ajax however I didn’t know if there was something quicker to utilize?


Viewing 1 replies (of 1 total)
  • Moderator bcworkz


    Don’t forget the option form popup is running on the user’s browser. The only communication with your server is by some sort of http protocol. Your only real choices are either request a new page or use ajax. Of course, you don’t necessarily need to respond with xml with ajax, any data form will work as long as the receiving script knows how to deal with it.

Viewing 1 replies (of 1 total)
  • The topic ‘Querying the wpdb from within a custom tinyMCE button popup’ is closed to new replies.