Submit form to db

You are serializing your form data before posting it to your PHP function, but you do not unserialize it at the other end. Therefore your check for $_POST[‘attend’] == ‘yes’will always fail. Try the following (untested). function eventAttend() { $fields = array( ); parse_str( $_POST[‘data’], $fields ); if($fields[‘attend’] == ‘yes’) { global $wpdb; $wpdb->insert(‘wp_event_attendants’, array( … Read more

Using color schemes with Color Picker

Don’t save everything as individual options, save all of your options as an array under a single key. One query to load it and save it, then just do all your manipulation in php. example structure and output: $colors = array( ‘current_scheme’ => ‘user_scheme’, ‘preset_schemes’ => array( ‘red’ => array( ‘menu’ => ‘#CC0000’, ‘footer’ => … Read more

Display Custom Field in Sidebar if Value is Present

I think, you’re mistaken in how if works…? $post_meta = get_post_meta( $GLOBALS[‘wp_query’]->post->ID, ‘TourURL’, true ); if (! empty($post_meta)) echo ‘<p>Show Link</p>’; else echo ‘<p>No Link</p>’; This should do what you want – if I understood you correctly. // UPDATED

WordPress -> If Is Role Subscriber Show Image?

This <?php if ( current_user_can(‘contributor’) ) : ?> only checks the users capabilities and is used like this <?php if ( current_user_can(‘edit_post’) ) : ?> You could write a function like this in functions.php: function user_role_check( $role, $user_id = null ) { $user = wp_get_current_user(); if ( empty( $user ) ) return false; return in_array( … Read more

Finding and removing duplicates within WP Arrays

If you only want to collect the category+tag names into the output, you can try this <?php global $post; $words=array(); $tags = wp_get_post_tags($post->ID); foreach($tags as $tag){ $words[]=”%23″.$tag->name; } $cats = get_the_category($post->ID); foreach($cats as $cat){ $words[]=”%23″.$cat->name; } $words=array_unique($words); echo implode(” “,$words); ?>

go to home page when i select default in select-box

You can try this <script type=”text/javascript”> var dropdown = document.getElementById(“cat”); function onCatChange() { if ( dropdown.selectedIndex == 0 ) { location.href = “https://wordpress.stackexchange.com/questions/90797/<?php echo get_option(“home’);?>”; }else if ( dropdown.selectedIndex > 0 ) { location.href = “https://wordpress.stackexchange.com/questions/90797/<?php echo get_option(“home’);?>/?cat=”+dropdown.options[dropdown.selectedIndex].value; } } dropdown.onchange = onCatChange; </script>

linked php file not executing php

The problem is not that the PHP doesn’t execute. It does execute but you get fatal errors because you are loading your template files directly, which means they are loading without the WordPress framework that supplies necessary functions. View source of those pages and you can see error. You should not be linking directly to … Read more

the_post_thumbnail issues

the_post_thumbnail() prints the HTML immediately. Use get_the_post_thumbnail() instead to get the HTML into your string. $content .= ‘<div class=”thumbnail”>’ . get_the_post_thumbnail( null, “home-post-thumbnail”) . ‘</div>’;