How To Disable Post Revision In WordPress
Simply add the following snippet to your theme’s wp-config.php file and you will be able to disable WordPress post revision.
1 |
define('WP_POST_REVISIONS', false); |
Snippet source/Credit: lesterchan.net
How To Have WordPress Domain Check
Using the following snippet will let you have your WordPress domain check.
1 2 3 4 5 6 7 8 9 10 |
<?php $loc = $_SERVER['REQUEST_URI']; $locDomain = $_SERVER['HTTP_HOST']; $posDomain = strpos($locDomain, 'travismathew.ca'); ?> <?php if ($posDomain !== false) { ?> <!-- CANADIAN --> <?php } else { ?> <!-- UNITED STATES --> <?php } ?> |
Snippet Source/Credit: Snipplr
How To Speed Up Your Blog By Adding Caching Custom Queries
Using the following snippet, you will be able to speed up your blog by adding caching custom queries.
1 2 3 4 5 6 7 8 9 |
<?php // Get any existing copy of our transient data if ( false === ( $special_query_results = get_transient( 'special_query_results' ) ) ) { // It wasn't there, so regenerate the data and save the transient $special_query_results = new WP_Query( 'cat=5&order=random&tag=tech&post_meta_key=thumbnail' ); set_transient( 'special_query_results', $special_query_results ); } // Use the data like you would have normally... ?> |
Snippet Source/Credit: WordPress Codex
How To Remove News Feed In WordPress Dashboard
The following snippet will let you remove news feed from your WordPress dashboard.
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 |
add_action('wp_dashboard_setup', 'my_dashboard_widgets'); function my_dashboard_widgets() { global $wp_meta_boxes; // remove unnecessary widgets // var_dump( $wp_meta_boxes['dashboard'] ); // use to get all the widget IDs unset( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins'], $wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary'], $wp_meta_boxes['dashboard']['side']['core']['dashboard_primary'] ); // add a custom dashboard widget wp_add_dashboard_widget( 'dashboard_custom_feed', 'News from 10up', 'dashboard_custom_feed_output' ); //add new RSS feed output } function dashboard_custom_feed_output() { echo '<div class="rss-widget">'; wp_widget_rss_output(array( 'url' => 'http://www.get10up.com/feed', 'title' => 'What\'s up at 10up', 'items' => 2, 'show_summary' => 1, 'show_author' => 0, 'show_date' => 1, )); echo "</div>"; } |
Snippet Source/Credit: Smashing Magazine
How To Show Content For Logged In Users
Adding this snippet to your theme’s functions.php file will let you show content only for logged in users.
1 2 3 4 5 6 7 8 9 10 |
<?php add_shortcode("hide","hide_shortcode"); function hide_shortcode($x,$text=null){ if(!is_user_logged_in()){ return "You have to been registered and logged in to see this content"; }else{ return do_shortcode($text); } } ?> |
Snippet Source/Credit: Snipplr