• Hi guys,
    I am trying to create a custom dropdown (select) box in my Contactform 7 with custom table from ai1ec_events table.
    this is my code but i have a problem because return only pagetitle field, not correct value.

    can you help me, please?

    wpcf7_add_shortcode('postdropdown', 'createbox', true);
    function createbox(){
    global $wpdb;
    $campocustom = $wpdb->get_results( "SELECT * FROM db_ippbrescia.wpipp_ai1ec_events WHERE contact_name IS NOT NULL AND contact_name != '';" );
    $output = "<select name='contact_name' id='contact_name' onchange='document.getElementById(\"cursus\").value=this.value;'><option></option>";
    foreach ( $campocustom as $post ) : setup_postdata($post);
    $title = get_the_title();
    $output .= "<option value='$title'> $title </option>";
    endforeach;
    $output .= "</select>";
    return $output;
    }
  • The topic ‘CF7 – Create a selectbox from database?’ is closed to new replies.