if(is_admin()) {
wp_enqueue_script('jquery-ui-datepicker');
wp_enqueue_script('custom-js', get_template_directory_uri().'/js/custom-js.js');
wp_enqueue_style('jquery-ui-custom', get_template_directory_uri().'/css/jquery-ui-custom.css');
}
function my_admin_footer() {
?>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('#registration_lastdate').datepicker({
dateFormat : 'd M yy'
});
jQuery('#training_date').datepicker({
dateFormat : 'd M yy'
});
});
</script>
<?php
}
add_action('admin_footer', 'my_admin_footer');
Monday, August 13, 2012
Using jQuery UI datepicker with WordPress custom post meta
Monday, August 6, 2012
Custom page links without or with a list
$args = array(
'orderby' => 'post_title',
'order' => 'ASC',
'post_type' => 'page',
//'post_parent'=> '35',
'caller_get_posts' => 1
);
$pages = get_posts($args);
foreach($pages as $page) {
$out .= '<div class="bluecategory_wrapper">';
$out .= '<a href="'.get_permalink($page->ID).'" title="'.wptexturize($page->post_title).'">
<div class="bluecategory_left"></div><div class="bluecategory_bg">'.wptexturize($page->post_title).'</div>
<div class="bluecategory_right"></div></a></div>';
}
$out = $out;
echo $out;
Thursday, August 2, 2012
Change WordPress “from” email header
By default, the default WordPress email adress looks like
WordPress@yoursitename.com. Want to use your real email and username
instead?
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');
Sending users email on post publish
function send_email_publish_post($post_ID) {
global $wpdb;
$permalink = get_permalink( $post_ID ); $query = "SELECT * FROM {$wpdb->users}"; $users = $wpdb->get_results( $query); foreach($users as $user) { $permalink = get_permalink( $post_ID ); $message="A New Post published. You can view the post details from the link ".$permalink." This is an auto generated notification. Please do not reply to it."; wp_mail( $user->user_email, "A New Post published", $message); } return $post_ID; } add_action('wp_publish_post','send_email_publish_post');
Wednesday, August 1, 2012
add theme support
add_theme_support( $feature );
$feature
- 'post-formats'
- 'post-thumbnails'
- 'custom-background'
- custom-header'
- 'automatic-feed-links'
- 'menus'
Enabling Support for Post Thumbnails
add_theme_support( 'post-thumbnails' );
Default Usage
if ( has_post_thumbnail() ) {
the_post_thumbnail();
}
Thumbnail Sizes
the_post_thumbnail(); // without parameter -> Thumbnail
the_post_thumbnail('thumbnail'); // Thumbnail (default 150px x 150px max)
the_post_thumbnail('medium'); // Medium resolution (default 300px x 300px max)
the_post_thumbnail('large'); // Large resolution (default 640px x 640px max)
the_post_thumbnail( array(100,100) ); // Other resolutions Example of a new Post Thumbnail size named "category-thumb".
add_image_size( 'category-thumb', 300, 9999 ); //300 pixels wide (and unlimited height)
Here is an example of how to use this new Post Thumbnail size in theme template files.
the_post_thumbnail( 'category-thumb' );
Custom Backgrounds
add_theme_support( 'custom-background' ); Note that you can add default arguments using:
$defaults = array(
'default-color' => '', 'default-image' => '', 'wp-head-callback' => '_custom_background_cb', 'admin-head-callback' => '',
'admin-preview-callback' => ''
); add_theme_support( 'custom-background', $defaults ); Example An example using default '#000000' background color with 'background.jpg' background image:
$args = array(
'default-color' => '000000', 'default-image' => get_template_directory_uri() . '/images/background.jpg',
); add_theme_support( 'custom-background', $args );
Subscribe to:
Posts (Atom)