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

Get value from db for custom contact form

Add this at the start of your process.php file to get access to get_option and other wordpress functions: define( ‘WP_USE_THEMES’, false ); require(‘wp-blog-header.php’); You might have to change the path to wp-blog-header.php.

WordPress Settings API settings not saving for some users

Here are few remarks after skimming through your code: you are using options name like id, title and global. You should use a prefix on these names, like vegas_, to avoid possible problems with other stuff using these option names. you should let the users know about validation problems (check out the add_settings_error() function) use … Read more

What could cause a WP Option to get truncated?

It was a 👼 character. Make sure you sanitize everything that gets written as field values, even if it’s a username. trim(preg_replace(“/[^\w\s]+/”, “”, $user->full_name)) I assumed there are no special characters in Instagram usernames. Never assume. I don’t really use Instagram, just my plugin supports it. BTW it got truncated on the first occurrence of … Read more

Accept code input into Options Framework

A better approach would be to have the user simply enter their tracking script ID. You know, something like UA-XXXXXXX-XX? Then in your header.php, output the standard tracking script: <?php if ( $ga = get_option( ‘google_analytics’ ) ) : ?> <script> var _gaq = _gaq || []; _gaq.push([‘_setAccount’, ‘<?php echo esc_js( $ga ) ?>’]); _gaq.push([‘_trackPageview’]); … Read more

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