Display random image url from list of input values

Instead of echoing out these images, just store them as strings inside an array and choose one of the array items at random. <?php $headerimage_options = get_option(‘headerimage_options’ ); $images = array(); $images[] = ‘<img title=”‘.get_bloginfo(‘name’).'” src=”‘.esc_url( $headerimage_options[‘image’] ).'”/>’; $images[] = ‘<img title=”‘.get_bloginfo(‘name’).'” src=”‘.esc_url( $headerimage_options[‘image2′] ).'”/>’; $images[] = ‘<img title=”‘.get_bloginfo(‘name’).'” src=”‘.esc_url( $headerimage_options[‘image3′] ).'”/>’; $v = array_rand($images); … Read more

Adding a single text input field to a custom Dashboard widget

You need a set of functions to : process datas sanitize options allow datas to be updated output the form I like to proceed this way. I set also a function to grab datas so I can call them the simpliest way : add_action(‘wp_dashboard_setup’, ‘wpse_106458_add_widget’); function wpse_106458_add_widget() { $title = my_function_get_options(); $title = $title[‘title’]; wp_add_dashboard_widget(‘widget_id’, … Read more

Input with pattern not working

Most likely because widgets are saved via AJAX, and, as far as I’m aware, the submit handler will bypass any HTML5 input rules unless they are explicitly checked with JavaScript. Your best bet is to validate/sanitize the data server-side, and pass back any messages if there is an input error. Chrome adding =”” is just … Read more

WP Page Options Array

After much experimentation I resolved my own question and this answer might help somebody. function mmm_select_field( ) { $options = get_option( ‘mmm_settings’ ); $buttons = array( ‘Bold’ => ‘bold’, ‘Italic’ => ‘italic’, ‘Underline’ => ‘underline’, ‘Superscript’ => ‘superscript’, ‘Align Left’ => ‘alignleft’, ‘Align Center’ => ‘aligncenter’, ‘Align Right’ => ‘alignright’, ‘Bullet List’ => ‘bulletlist’, ‘Number … Read more

How to add a placeholder to the protected post password input

This can be achieved via a hook, called the_password_form: function my_theme_password_placeholder($output) { $placeholder=”Hello!”; $search=”type=”password””; return str_replace($search, $search . ” placeholder=\”$placeholder\””, $output); } add_filter(‘the_password_form’, ‘my_theme_password_placeholder’); A str_replace searches for the string type=”password” inside the output. This gives an attribute to the <input> indicating it’s of type password. The replacement string contains the searched one plus the … Read more

get value from selected input

Well, I don’t know how many input type of radios and checkboxes you have, but this should get you want you need: $(document).ready(function() { $(‘input:radio’).change(function() { // get the value var newValue = $(this).val(); // Update the div.score $(‘div.score’).text(newValue); }); }); PS: Your radio input need to have the same name, if you do not … Read more

Use of http form post

Honestly, your best bet is to actually use $_POST to process this logic. In your form, your submit buttons lack a name attribute which would allow you to do this: <form method=”post” action=”http://xxx.yyy/wp-admin/admin-post.php”> <td width=”60″ height=”26″> <input type=”submit” value=”Lot #” name=”lot”> </td> <td width=”154″ > <input type=”submit” value=”Name” name=”name”> </td> <td width=”154″> <input type=”submit” value=”Subdivision … Read more

Frontend Category Checkbox

Your select tag doesn’t have a name attribute, it only has a type and value. The name is used as an ID when you POST most likely the reason your data isn’t saving. Quick Example: <form action=”/action_page.php”> <select name=”cars”> <option value=”volvo”>Volvo XC90</option> <option value=”saab”>Saab 95</option> <option value=”mercedes”>Mercedes SLK</option> <option value=”audi”>Audi TT</option> </select> <input type=”submit” value=”Submit”> … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)