How To Schedule Events In Your WordPress Website
The following snippet will let you schedule events in your WordPress website.
1 2 3 4 5 6 7 |
if (!wp_next_scheduled('my_task_hook')) { wp_schedule_event( time(), 'hourly', 'my_task_hook' ); } add_action( 'my_task_hook', 'my_task_function' ); function my_task_function() { wp_mail('you@yoursite.com', 'Automatic email', 'Hello, this is an automatically scheduled email from WordPress.'); } |
How To Set PHP Memory Limit In Htaccess
The snippet below will be useful for WordPress installations that need more than 32M of memory.
1 |
php_value memory_limit 64M |
Snippet Source/Credit: darrenhuskie.com
How To Show Posts For Category
You do turn selective one-to-many times in choosing the posts for category. While the thing can be achieved by manually but to ease the job, using the snippet below you can show posts for category as per the way you want.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
/** * Show latest posts for category * * @return * @param object $cats * @param object $show[optional] */ function show_title_cat( $cats, $show=5 ) { global $post; $posts = query_posts('cat=' . $cats . '&showposts=' . $show ); echo "<ul>"; foreach ($posts as $post ) : setup_postdata($post); ?> <li><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></li> <?php endforeach; echo "</ul>"; } |
Snippet Source/Credit: undolog.com
How To Use Gravatar Image As WordPress Favicon
The following snippet below will let you use gravatar image as WordPress favicon.
1 2 3 4 5 6 |
// add gravatar favicon to site, 16x16 favicon.ico function snix_add_favicon() { $GetTheHash = md5(strtolower(trim('scott@scottnix.com'))); ?><link rel="shortcut icon" href="<?php echo 'http://www.gravatar.com/avatar/' . $GetTheHash . '?s=16;'; ?>" /><?php } add_action('wp_head', 'snix_add_favicon'); |
Snippet Source/Credit: forrst.com
How To Use Gravatars In Your Script
With the use of following snippet below, you will be able to use Gravatars in your script.
1 2 3 4 5 6 7 8 |
<?php function show_my_gravatar($email, $size, $default, $rating) { $params = '?gravatar_id='.md5($email).'&default='.$default.'&size='.$size.'&rating='.$rating; $output = '<img src="http://www.gravatar.com/avatar.php'.$params.'" width="'.$size.'px" height="'.$size.'px" />'; echo $output; } ?> |
Snippet Source/Credit: apphp.com