How To Change WordPress Login Logo Title Attribute
Using the following snippet, you will be able to change WordPress login logo title attribute.
1 2 3 4 |
function custom_login_title() { return 'Your desired text'; } add_filter('login_headertitle', 'custom_login_title'); |
Snippet Source/Credit: Dave Clements
How To Load All Posts From The Current Week
Using the following snippet, you will be able to load all posts from the current week.
1 2 3 4 5 6 |
// display posts as desired query_args = array( 'w' => date( 'W' ), 'year' => date( 'Y' ), ); $posts = get_posts( $query_args ); |
Source Snippet/Code: Christian Brückner
How To Add A Custom Message To The Editor Pane
Using the following snippet, you will be able to add a custom message to the editor pane.
1 2 3 4 5 6 7 8 9 |
function wptutsplus_text_after_title( $post_type ) { ?> <div class="after-title-help postbox"> <h3>Using this screen</h3> <div class="inside"> <p>Use this screen to add new articles or edit existing ones. Make sure you click 'Publish' to publish a new article once you've added it, or 'Update' to save any changes.</p> </div><!-- .inside --> </div><!-- .postbox --> <?php } add_action( 'edit_form_after_title', 'wptutsplus_text_after_title' ); |
Snippet Source/Credit: WP Tuts
How To Remove Widgets From WordPress Dashboard
Using the following snippet, you will be able to remove widgets from WordPress dashboard.
1 2 3 4 5 6 7 |
//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'); |
Snippet Source/Credit: WP Guru
How To Delete WordPress Post Revisions Using Your Functions.php File
Using the following snippet, you will be able to delete WordPress post revision using your functions.php file.
1 2 3 4 |
$wpdb->query( " DELETE FROM $wpdb->posts WHERE post_type = 'revision' " ); |
Snippet Source/Credit: Hardeep Asrani
How To Add A Link To Your Post Using RSS Feed
Using the following snippet, you will be able to add a link to your post using RSS feed.
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 |
<?php /* Template Name: Custom Feed */ $numposts = 5; function yoast_rss_date( $timestamp = null ) { $timestamp = ($timestamp==null) ? time() : $timestamp; echo date(DATE_RSS, $timestamp); } function yoast_rss_text_limit($string, $length, $replacer = '...') { $string = strip_tags($string); if(strlen($string) > $length) return (preg_match('/^(.*)\W.*$/', substr($string, 0, $length+1), $matches) ? $matches[1] : substr($string, 0, $length)) . $replacer; return $string; } $posts = query_posts('showposts='.$numposts); $lastpost = $numposts - 1; header("Content-Type: application/rss+xml; charset=UTF-8"); echo '<?xml version="1.0"?>'; ?><rss version="2.0"> <channel> <title>Yoast E-mail Update</title> <link>http://yoast.com/</link> <description>The latest blog posts from Yoast.com.</description> <language>en-us</language> <pubDate><?php yoast_rss_date( strtotime($ps[$lastpost]->post_date_gmt) ); ?></pubDate> <lastBuildDate><?php yoast_rss_date( strtotime($ps[$lastpost]->post_date_gmt) ); ?></lastBuildDate> <managingEditor>joost@yoast.com</managingEditor> <?php foreach ($posts as $post) { ?> <item> <title><?php echo get_the_title($post->ID); ?></title> <link><?php echo get_permalink($post->ID); ?></link> <description><?php echo '<![CDATA['.yoast_rss_text_limit($post->post_content, 500).'<br/><br/>Keep on reading: <a href="'.get_permalink($post->ID).'">'.get_the_title($post->ID).'</a>'.']]>'; ?></description> <pubDate><?php yoast_rss_date( strtotime($post->post_date_gmt) ); ?></pubDate> <guid><?php echo get_permalink($post->ID); ?></guid> </item> <?php } ?> </channel> </rss> |
Snippet Source/Credit: Yoast