How to change the default WordPress email from and address
By default, emails sent from your wordpress blog will display from WordPress
Add the following snipit of code to your functions.php file in your wordpress theme.
function res_fromemail($email) {
$wpfrom = get_option('admin_email');
return $wpfrom;
}
function res_fromname($email){
$wpfrom = get_option('blogname');
return $wpfrom;
}
add_filter('wp_mail_from', 'res_fromemail');
add_filter('wp_mail_from_name', 'res_fromname');
Thank you KeenTricks.com.
How to create and insert a custom field automatically when a post is published
Found on WPRecipes.
This is sweet little helper… and if you’ve ever wanted to be able to automatically create a custom field with a value when a post (or page) is created, this little snippet of WordPRess code is for you.
It is to be added to your Functions.php file within your theme. Simply change the “field-name” and “custom value” to make it work.
add_action('publish_page', 'add_custom_field_automatically');
add_action('publish_post', 'add_custom_field_automatically');
function add_custom_field_automatically($post_ID) {
global $wpdb;
if(!wp_is_post_revision($post_ID)) {
add_post_meta($post_ID, 'field-name', 'custom value', true);
}
}
Seconds Ago Script using $UNIXTIMESTAMP
I discovered this little post by Alex Whinfield that just made me so happy. I just know that it will make you happy too. It’s a “Seconds Ago” counter that uses the $UNIXTIMESTAMP php call to calculate a time since. Works great and is very light. Get the code here.
If In Category – A WordPress Hack
I recently had a need where content needed to be included in a certain blog category and not in others. The content will only display post is in the specified category. You can use the category slug or the category ID.
<?php if (in_category('1')); ?>
<div class='someclass'>
<p>Some Content</p>
</div>
<?php endif; ?>
