Repeatable custom meta select boxes

To make this work… $meta == $item->ID ? ‘ selected=”selected”‘ : ”; … with an array like a:1:{i:0;s:3:”179″;} which unserializes to… Array ( [0] => 179 ) … you’d need to do this: $meta = unserialize($meta); $meta[0] == $item->ID ? ‘ selected=”selected”‘ : ”; But that line shows up inside a foreach like foreach($meta as … Read more

How do I capture the selected option and pass in sending the registration form?

Way use jQery to populate the select field when you can use filter and hook into the form using PHP eg: //1. Add a new form element… add_action(‘register_form’,’_register_form_wpa103118′); function _register_form_wpa103118 (){ $name_of_select = ( isset( $_POST[‘name_of_select’] ) ) ? $_POST[‘name_of_select’]: ”; $options = array( ‘Medicine’ => ‘Medicine’, ‘Option2’ => ‘Option2’, ); ?> <p> <label for=”name_of_select”><?php … Read more

Select Menu for Custom post Type does not save

This is a javascript issue. on line 52: $ret .= ‘<script>jQuery(document).ready(function(){ jQuery(“#videotype”).val(‘ . get_video_field(“videotype”) . ‘) });</script></div>’; In this specific bit: .val(‘ . get_video_field(“videotype”) . ‘) The value isn’t quoted, so it’s trying to reference a variable named youtube or vimeo, which doesn’t exist, instead of a literal text value. If you add quotes it’ll … Read more

Get post title by Alphabet

You have two problems. First need to global $wpdb;. Then you are using the_title() and the_permalink() both of which automatically echo out a value. So you need to switch them to get_the_title() and get_permalink(). function get_post_by_alphabet($the_char){ global $wpdb; $first_char = $the_char; $postids=$wpdb->get_col($wpdb->prepare(” SELECT ID FROM $wpdb->posts WHERE SUBSTR($wpdb->posts.post_title,1,1) = %s ORDER BY $wpdb->posts.post_title”,$first_char)); if ($postids) … Read more

wpdb select from using array as search parameters

Pass your information through prepare as in this example from the Codex: $metakey = “Harriet’s Adages”; $metavalue = “WordPress’ database interface is like Sunday Morning: Easy.”; $wpdb->query( $wpdb->prepare( ” INSERT INTO $wpdb->postmeta ( post_id, meta_key, meta_value ) VALUES ( %d, %s, %s ) “, array( 10, $metakey, $metavalue ) ) ); Your array should have … Read more