How To Disable Comments Completely In WordPress
Adding the following snippet will let you disable Word Press comments completely.
1 |
<?php return false; ?> |
Snippet Source/Credit: aotearoawebdesign.co.nz
How To Limit Posts Per Page On Search In WordPress
Using the following snippet will let you limit posts per page on search page in WordPress.
1 2 3 4 5 |
function limit_posts_per_search_page() { if ( is_search() ) set_query_var('posts_per_archive_page', 20); } add_filter('pre_get_posts', 'limit_posts_per_search_page'); |
Snippet Source/Credit: WordPress.org
Fixing HTTP Error In WordPress
Using the following snippet in your theme’s .htaccess code will let you fix HTTP error in WordPress.
1 2 3 4 5 6 |
<IfModule mod_security.c> <Files async-upload.php> SecFilterEngine Off SecFilterScanPOST Off </Files> </IfModule> |
How To Know That Which Theme You Are Using
Adding the following lines of code will let you know that which theme you are using.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
add_action( 'wp_head', 'show_me_the_template' ); function show_me_the_template() { global $template, $current_user, $wp_admin_bar; get_currentuserinfo(); /* If you have more than one user deny. Be sure to use your user ID! */ if ( !is_user_logged_in() && $current_user->ID != '1' ) return; if ( is_admin_bar_showing() ) $wp_admin_bar->add_menu( array( 'parent' => false, 'id' => 'template', 'title' => $template, 'href' => '#' )); else print_r( $template ); } |
Snippet Source/Credit: Snipplr
How To Change Editor Font In WordPress
Using the snippet below and you will be able to change the font the way you want.
1 2 3 4 5 |
add_action( 'admin_head-post.php', 'devpress_fix_html_editor_font' ); add_action( 'admin_head-post-new.php', 'devpress_fix_html_editor_font' ); function devpress_fix_html_editor_font() { ?> <style type="text/css">#editorcontainer #content, #wp_mce_fullscreen { font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif; }</style> <?php } |
Snippet Source/Credit: DevPress
How To Disable Plugins Update In Your WordPress Blog
Using the following snippet, you will be able to disable all the plugins in your WordPress blog.
1 2 |
remove_action( 'load-update-core.php', 'wp_update_plugins' ); add_filter( 'pre_site_transient_update_plugins', create_function( '$a', "return null;" ) ); |
Snippet Source/Credit: WP Snippets
How To Set A Maximum Word Count On Post Titles
Adding the following snippet to your theme’s functions.php file, you will be able to set a maximum word count on post titles.
1 2 3 4 5 6 7 |
function maxWord($title){ global $post; $title = $post->post_title; if (str_word_count($title) >= 10 ) //set this to the maximum number of words wp_die( __('Error: your post title is over the maximum word count.') ); } add_action('publish_post', 'maxWord'); |
Snippet Source/Credit: Pippin