Category: Wordpress

Upload SWF file in wordpress

Here is the code to Upload swf file in wordpress. function swf_upload($mimes) { if (function_exists(‘current_user_can’)){ $unfiltered = $user ? user_can($user, ‘unfiltered_html’) : current_user_can(‘unfiltered_html’); } if (!empty($unfiltered)) { $mimes[‘swf’] = ‘application/x-shockwave-flash’; } return $mimes; } add_filter(‘upload_mimes’, ‘swf_upload’); We can use Kimili Flash plugin to embed the flash file.

Read More…

Clear form fields after finishing ajax submit using Jquery

Use reset() method to clear form fields after submitting the form via ajax. $.ajax({ type:"POST", url:formUrl, data:formData, beforeSend:function(){ $(‘.status’).html(‘<b>Form is being submitted</b>’); }, success:function(data){ $(‘. status ‘).html(‘<b>Thank you!! We have received your form</b>’); }, complete:function(){ $(‘#form-id’).each(function(){ this.reset(); //Here form fields will be cleared. }); }});

Read More…

Get custom field value through shortcode

Creating wordpress short-codes is simple. We can access custom field value through shortcode, just follow the function. add_shortcode(‘field’, ‘shortcode_field’); function shortcode_field($atts){ extract(shortcode_atts(array( ‘post_id’ =&gt; NULL, ), $atts)); if(!isset($atts[0]) return; $field = esc_attr($atts[0]); global $post; $post_id = (NULL === $post_id) ? $post->ID : $post_id; return get_post_meta($post_id, $field, true); } Usage: [field "my_key"] [field "my_key" post_id=1]

Read More…

Include or exclude custom post types in wordpress search result

Defining post types in search query allows you to include or exclude the custom post types in wordpress search result. Just add this function to functions.php // MAKE CUSTOM POST TYPES SEARCHABLE function searchAll( $query ) { if ( $query->is_search ) { $query->set( ‘post_type’, array( ‘site’,’plugin’, ‘theme’,’person’ )); } return $query; } add_filter( ‘the_search_query’, ‘searchAll’ […]

Read More…