Custom login
1 2 3 4 5 6 7 |
function custom_login() { echo '<link rel="stylesheet" type="text/css" href="'.get_bloginfo('template_directory').'/resources/css/login.css" />'; } add_action('login_head', 'custom_login'); |
Source: Snipplr
Add featured image thumbnail to admin columns
The following snippet will add featured image thumbnail to admin columns
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
// Add the posts and pages columns filter. They can both use the same function. add_filter('manage_posts_columns', 'tcb_add_post_thumbnail_column', 5); add_filter('manage_pages_columns', 'tcb_add_post_thumbnail_column', 5); // Add the column function tcb_add_post_thumbnail_column($cols){ $cols['tcb_post_thumb'] = __('Featured'); return $cols; } // Hook into the posts an pages column managing. Sharing function callback again. add_action('manage_posts_custom_column', 'tcb_display_post_thumbnail_column', 5, 2); add_action('manage_pages_custom_column', 'tcb_display_post_thumbnail_column', 5, 2); // Grab featured-thumbnail size post thumbnail and display it. function tcb_display_post_thumbnail_column($col, $id){ switch($col){ case 'tcb_post_thumb': if( function_exists('the_post_thumbnail') ) echo the_post_thumbnail( 'admin-list-thumb' ); else echo 'Not supported in theme'; break; } } |
Source: TCBarrett.com
View wp-posts in dropdown
The following snippet will allow you to view WP-Posts in dropdown
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
<form action="<? bloginfo('url'); ?>" method="get"> <select name="page_id" id="page_id"> <?php global $post; $args = array( 'numberposts' => -1); $posts = get_posts($args); foreach( $posts as $post ) : setup_postdata($post); ?> <option value="<? echo $post->ID; ?>"><?php the_title(); ?></option> <?php endforeach; ?> </select> <input type="submit" name="submit" value="view" /> </form> |
Source: Snipplr
Move and rename “Featured Image” box
The following code will move and rename “Featured Image” box
1 2 3 4 5 6 7 8 9 10 11 12 13 |
function customposttype_image_box() { remove_meta_box('postimagediv', 'home-page-banners', 'side'); remove_meta_box('postimagediv', 'page', 'side'); add_meta_box('postimagediv', __('Banner Image - The image that appears at the top of the page, size should be 760 x 155 pixels'), 'post_thumbnail_meta_box', 'page', 'normal', 'high'); add_meta_box('postimagediv', __('Banner Image - 760 x 390 pixels - Bigger images will be cropped automatically.'), 'post_thumbnail_meta_box', 'home-page-banners', 'normal', 'high'); } add_action('do_meta_boxes', 'customposttype_image_box'); |
Source: WordPress.org
Limit Search Results to Specific Post Types
The following snippet will limit search results to specific post types
1 2 3 4 5 6 7 8 9 10 11 12 13 |
function SearchFilter($query) { if ($query->is_search) { $query->set('post_type',array('post','page')); } return $query; } add_filter('pre_get_posts','SearchFilter'); |
Source: Snipplr
Current theme link for WordPress theme
The following snippet will link to the current theme/template url for use in WordPress template
1 |
<?php bloginfo('template_url'); ?> |
How to Easily Disable Theme Changing
The following snippet will easily disable theme changing
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
add_action('admin_init', 'slt_lock_theme'); function slt_lock_theme() { global $submenu, $userdata; get_currentuserinfo(); if ($userdata->ID != 1) { unset($submenu['themes.php'][5]); unset($submenu['themes.php'][15]); } } |
Share wp-articles on Twitter
The following snippet will share wp-articles on Twitter
1 2 3 |
<?php $excerpt = strip_tags(get_the_excerpt()); ?> <a href="http://twitter.com/home?status=<?php the_title(); ?><?php echo $excerpt; ?>" rel="nofollow" title="retweet on twitter">Share on Twitter</a> |
Photo Credit: Flickr/hackNY.org