Redirecting To A Custom Page After Registration
The addition of the following snippet in your theme’s functions.php will let you redirect to a custom page after registration.
1 2 3 4 5 6 7 |
function __my_registration_redirect(){ return home_url( '/my-page' ); } add_filter( 'registration_redirect', '__my_registration_redirect' ); |
Source: TheDeadMedic
Adding Custom Text To WordPress Loging Page
The following snippet will allow you to add custom text to WordPress login page.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
function wps_login_message( $message ) { if ( empty($message) ){ return "<p class='message'>Welcome to this site. Please log in to continue</p>"; } else { return $message; } } add_filter( 'login_message', 'wps_login_message' ); |
Source: WP Snippy
Author Bio Excerpt
Addition of the following snippet to your theme’s functions.php file will let you show an author bio excerpt.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<?php function author_excerpt (){ $word_limit = 20; // Limit the number of words $more_txt = 'read more about:'; // The read more text $txt_end = '...'; // Display text end $authorName = get_the_author(); $authorUrl = get_author_posts_url( get_the_author_meta('ID')); $authorDescriptionShort = wp_trim_words(strip_tags(get_the_author_meta('description')), $word_limit, $txt_end.'<br /> '.$more_txt.' <a href="'.$authorUrl.'">'.$authorName.'</a>'); return $authorDescriptionShort; } ?> |
Once done, using the following snippet will like to display an author bio excerpt.
1 |
<?php if (function_exists('author_excerpt')){echo author_excerpt();} ?> |
Source: Tim Marcher
Automatically Adding Gravatars For The Post Authors
The following snippet will automatically add gravatars for the post authors.
1 |
<?php echo get_avatar( get_the_author_email(), '80' ); ?> |
Source: Emoticode
Changing Author URL Base
Using the following snippet will change author url base on your WordPress website.
1 2 3 4 5 6 7 8 9 10 11 |
add_action('init', 'cng_author_base'); function cng_author_base() { global $wp_rewrite; $author_slug = 'profile'; // change slug name $wp_rewrite->author_base = $author_slug; } |
Source: Kevin Chard
Removing Widgets From WordPress Dashboard
Addition of the following snippet in your theme’s functions.php file will let you remove widgets from your WordPress dashboard.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
//Remove unwanted widgets from Dashboard function remove_dashboard_widgets() { global$wp_meta_boxes; unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']); unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']); } add_action('wp_dashboard_setup', 'remove_dashboard_widgets'); |
Source: WP Guru
Paginating WordPress Just Like Dribbble
The following snippet will paginate your WordPress website just like dribbble.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<?php $prev = get_previous_post(); $next = get_next_post(); <div class="float--left folio"> <a href="<?php echo get_permalink($prev->ID); ?>" title="<?php echo esc_attr($prev->post_title); ?>"> <?php echo get_the_post_thumbnail($prev->ID, 'thumbnail'); ?> </a> </div> <div class="float--right folio"> <a href="<?php echo get_permalink($next->ID); ?>" title="<?php echo esc_attr($next->post_title); ?>"> <?php echo get_the_post_thumbnail($next->ID, 'thumbnail'); ?> </a> </div> |
Source: Elliott Richmond
Email Alert For 404s
Quite possible the time when you want to keep track of 404 page on your website. Instead of doing this manually by keeping a track via log files, the addition of following snippet will ease your job.
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 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
<?php // WP 404 ALERTS @ http://wp-mix.com/wordpress-404-email-alerts/ // set status header("HTTP/1.1 404 Not Found"); header("Status: 404 Not Found"); // site info $blog = get_bloginfo('name'); $site = get_bloginfo('url') . '/'; $email = get_bloginfo('admin_email'); // theme info if (!empty($_COOKIE["nkthemeswitch" . COOKIEHASH])) { $theme = clean($_COOKIE["nkthemeswitch" . COOKIEHASH]); } else { $theme_data = wp_get_theme(); $theme = clean($theme_data->Name); } // referrer if (isset($_SERVER['HTTP_REFERER'])) { $referer = clean($_SERVER['HTTP_REFERER']); } else { $referer = "undefined"; } // request URI if (isset($_SERVER['REQUEST_URI']) && isset($_SERVER["HTTP_HOST"])) { $request = clean('http://' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]); } else { $request = "undefined"; } // query string if (isset($_SERVER['QUERY_STRING'])) { $string = clean($_SERVER['QUERY_STRING']); } else { $string = "undefined"; } // IP address if (isset($_SERVER['REMOTE_ADDR'])) { $address = clean($_SERVER['REMOTE_ADDR']); } else { $address = "undefined"; } // user agent if (isset($_SERVER['HTTP_USER_AGENT'])) { $agent = clean($_SERVER['HTTP_USER_AGENT']); } else { $agent = "undefined"; } // identity if (isset($_SERVER['REMOTE_IDENT'])) { $remote = clean($_SERVER['REMOTE_IDENT']); } else { $remote = "undefined"; } // log time $time = clean(date("F jS Y, h:ia", time())); // sanitize function clean($string) { $string = rtrim($string); $string = ltrim($string); $string = htmlentities($string, ENT_QUOTES); $string = str_replace("\n", "<br>", $string); if (get_magic_quotes_gpc()) { $string = stripslashes($string); } return $string; } $message = "TIME: " . $time . "\n" . "*404: " . $request . "\n" . "SITE: " . $site . "\n" . "THEME: " . $theme . "\n" . "REFERRER: " . $referer . "\n" . "QUERY STRING: " . $string . "\n" . "REMOTE ADDRESS: " . $address . "\n" . "REMOTE IDENTITY: " . $remote . "\n" . "USER AGENT: " . $agent . "\n\n\n"; mail($email, "404 Alert: " . $blog . " [" . $theme . "]", $message, "From: $email"); ?> |
Source: WP Mix