Dropdown List Automatic Populate with Image ID's & Names
-
So I was trying to hack some stuff together to get something to work with Contact Form 7. I want one of my drop-downs on my form to be automatically populated with a list of all the ID’s and Picture titles that are in my galleries. Its basically a form where people can request a certain template, so they can see it in the gallery, and then use the dropdown to easily select the one they want.
I found this code below which allows a shortcode for CF7:
wpcf7_add_shortcode('postdropdown', 'createbox', true); function createbox(){ global $post; $args = array('numberposts' => 0, 'category' => 5 ); $myposts = get_posts( $args ); $output = "<select name='cursus' id='cursus' onchange='document.getElementById(\"cursus\").value=this.value;'><option></option>"; foreach ( $myposts as $post ) : setup_postdata($post); $title = get_the_title(); $output .= "<option value='$title'> $title </option>"; endforeach; $output .= "</select>"; return $output; }which populates a dropdown with post titles, but I wanted to hack it to show NGG image ID’s and Titles.
I don’t know PHP well enough to do it myself, and after lots of effort I’ve decided to come here for help. Anyone have any ideas?
The topic ‘Dropdown List Automatic Populate with Image ID's & Names’ is closed to new replies.