get Custom post page name
The following snippet will allow you to have custom post page name
1 2 3 4 5 |
<?php $post_type = get_post_type_object( get_post_type($post) ); echo $post_type->labels->singular_name ; ?> <a href="<? echo(get_page_link(get_page_by_title('Custom post page name')->ID)) ?>">Find out More</a> |
Source: Snipplr
Automatically Notify Your Members on New Posts
The following snippet will send an email to all registered users whenever a post is published
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 |
function email_members($post_ID) { //global $wpdb; //$usersarray = $wpdb->get_results("SELECT user_email FROM $wpdb->users;"); $wp_user_search = new WP_User_Query( array( 'fields' => array('user_email') ) ); $usersarray = $wp_user_search->get_results(); $arrUsers = array (); for ($arr = $usersarray, $mU = count ($arr), $iU = 0; $iU < $mU; $iU++) { $arrUsers[] = $arr[$iU]->user_email; } // for $users = implode(",", $arrUsers); mail($users, "New post notification : " . get_bloginfo('name') , "A new post has been published on " . get_bloginfo('siteurl') ); return $post_ID; } add_action('publish_post', 'email_members'); |
Alert Shortcodes
The following snippet will alert shortcodes
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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
// Alert Shortcodes function alert_green($atts, $content = null) { return'<div class="alert-green">' . $content . '</div>'; } add_shortcode('alert_green', 'alert_green'); function alert_blue($atts, $content = null) { return'<div class="alert-blue">' . $content . '</div>'; } add_shortcode('alert_blue', 'alert_blue'); function alert_yellow($atts, $content = null) { return'<div class="alert-yellow">' . $content . '</div>'; } add_shortcode('alert_yellow', 'alert_yellow'); function alert_red($atts, $content = null) { return'<div class="alert-red">' . $content . '</div>'; } add_shortcode('alert_red', 'alert_red'); /* Alert Shortcodes */ /* Buttons, message boxes, & alert boxes */ .alert-green { -moz-border-radius:3px; -webkit-border-radius:3px; border-radius:3px; background:#e5ffcc url(images/alert_green.png) left center no-repeat; color:#573; border:1px solid #bbdd99; padding:10px 10px 10px 40px; margin:10px 0 20px 0; } .alert_blue { -moz-border-radius:3px; -webkit-border-radius:3px; border-radius:3px; background:#e5f5ff url(images/alert_blue.png) left center no-repeat; color:#467; border:1px solid #bde; padding:10px 10px 10px 40px; margin:10px 0 20px 0; } .alert_yellow { -moz-border-radius:3px; -webkit-border-radius:3px; border-radius:3px; background:#ffd url(images/alert_yellow.png) left center no-repeat; color:#664; border:1px solid #ddc; padding:10px 10px 10px 40px; margin:10px 0 20px 0; } .alert_red { -moz-border-radius:3px; -webkit-border-radius:3px; border-radius:3px; background:#fcc url(images/alert_red.png) left center no-repeat; color:#744; border:1px solid #daa; padding:10px 10px 10px 40px; margin:10px 0 20px 0; } |
Source: Snipplr
Stop directory index browsing
The following snippet will stop directory index browsing
1 |
Options All -Indexes |
Source: Ubuntuguide
WordPress default CSS
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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
.alignnone { margin: 5px 20px 20px 0; } .aligncenter, div.aligncenter { display:block; margin: 5px auto 5px auto; } .alignright { float:right; margin: 5px 0 20px 20px; } .alignleft { float:left; margin: 5px 20px 20px 0; } .aligncenter { display: block; margin: 5px auto 5px auto; } a img.alignright { float:right; margin: 5px 0 20px 20px; } a img.alignnone { margin: 5px 20px 20px 0; } a img.alignleft { float:left; margin: 5px 20px 20px 0; } a img.aligncenter { display: block; margin-left: auto; margin-right: auto } .wp-caption { background: #fff; border: 1px solid #f0f0f0; max-width: 96%; /* Image does not overflow the content area */ padding: 5px 3px 10px; text-align: center; } .wp-caption.alignnone { margin: 5px 20px 20px 0; } .wp-caption.alignleft { margin: 5px 20px 20px 0; } .wp-caption.alignright { margin: 5px 0 20px 20px; } .wp-caption img { border: 0 none; height: auto; margin:0; max-width: 98.5%; padding:0; width: auto; } .wp-caption p.wp-caption-text { font-size:11px; line-height:17px; margin:0; padding:0 4px 5px; } |
Source: WordPressAPI
Anti-Word Alert
The following snippet will alert on anti-words
1 2 3 4 5 6 7 8 9 10 11 |
add_action( 'admin_notices', 'custom_admin_notice' ); function custom_admin_notice(){ global $current_screen; if ( $current_screen->parent_base == 'edit' ) echo '<div class="updated"><p><strong>NOTE</strong> - Please do not copy and paste text from Microsoft Word. You can write and save your post here in WordPress, or copy it from a plain text app (Notepad or TextEdit). Microsoft Word adds a ton of messy inline tags that break things.</p></div>'; } |
Add Custom Menu Support
The following snippet will add custom menu support
1 2 3 4 5 6 7 |
add_action('init', 'register_custom_menu'); function register_custom_menu() { register_nav_menu('custom_menu', __('Custom Menu')); } |
Source: ThinkVitamin
Get Image Path Relevant To Theme
The following snippet will get image path relevant to theme
1 |
<img src="<?php bloginfo('template_directory'); ?>/images/XXX.jpg" title="" alt="" /> |
Source: BrightCherry.co.uk
Gravatar Image as Favicon
The following snippet will let you have your Gravatar image as WordPress Favicon
1 2 3 4 5 6 7 |
function GravatarAsFavicon() { $GetTheHash = md5(strtolower(trim('you@yourdomain.com'))); echo 'http://www.gravatar.com/avatar/' . $GetTheHash . '?s=16'; } |
Source: Forrst
Photo Credit: Flickr/hackNY.org