Is there a way to define a default caption to all uploaded images

There’s really no documentation for it yet, but you’ll probably be able to do it hooking to the attachment_fields_to_save filter and inserting the default caption there. From the Codex: attachment_fields_to_save applied to fields associated with an attachment prior to saving them in the database. Called in the media_upload_form_handler function. Filter function arguments: an array of … Read more

How can I change the frequency of a scheduled event?

It looks for me that you are adding this event only when there is no such event ‘send_email_alerts_hook’ scheduled yet. Try something like this and let me know if it workded. function shedule_email_alerts() { if ( !wp_next_scheduled( ‘send_email_alerts_hook’ ) ) { wp_schedule_event(time(), ‘daily’, ‘send_email_alerts_hook’); } else { wp_reschedule_event(time(), ‘daily’, ‘send_email_alerts_hook’); } } The thing is … Read more

Importing Tweets with certain hashtags into WordPress

I wrote a shortcode function based on “Twitter Hash Tag Widget” plugin just copy this function to your themes functions.php file function tweets_by_hashtag_9867($atts, $content = null){ extract(shortcode_atts(array( “hashtag” => ‘default_tag’, “number” => 5, ), $atts)); $api_url=”http://search.twitter.com/search.json”; $raw_response = wp_remote_get(“$api_url?q=%23$hashtag&rpp=$number”); if ( is_wp_error($raw_response) ) { $output = “<p>Failed to update from Twitter!</p>\n”; $output .= “<!–{$raw_response->errors[‘http_request_failed’][0]}–>\n”; $output … Read more

Implementing advanced add_* function wrappers

For simple cases like quick one-liner returns one should remember that it’s possible to hook an anonymous function directly in the add filter call, e.g: add_filter(‘some_filter_hook’, function($v){return str_replace(‘..’, ‘.’, $v);}); add_action(‘some_action_hook’, function(){echo ‘….’;});

Dynamic template serving, change theme_root using add_filter from current theme

You could also write your own simple get_template_part alias function: The following allows 3 subfolders for template parts that sit in a theme root folder named devices. <?php // STYLESHEETS function print_device_styles( $client=”desktop” ) { $client = apply_filters( ‘set_theme_client’, $client ); wp_enqueue_style( $client.’-css’ ); } add_action( ‘wp_head’, ‘print_device_styles’, 11 ); // TEMPLATE PARTS function get_device_template_part( … Read more