WordPress.org

Ready to get started?Download WordPress

Forums

Querying the wpdb from within a custom tinyMCE button popup (2 posts)

  1. fanalejr
    Member
    Posted 1 year ago #

    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">
        <?php
        $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; ?>
        </select>

    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?

    Thanks

  2. bcworkz
    Member
    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic