How To Include jQuery In WordPress Theme
The following snippet will let you include jQuery in WordPress theme.
1 2 3 4 5 |
if( !is_admin()){ wp_deregister_script('jquery'); wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"), false, '1.3.2'); wp_enqueue_script('jquery'); } |
Snippet Source/Credit: Snipplr
How To Know That Which Template Are You Using In Your WordPress Website
Using the following snippet, you will be able to get to know that which template you are using in your WordPress website.
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 Move And Rename ‘Featured Image’ Box
Add the following snippet to your theme’s functions.php file will let you move and rename “featured image” box.
1 2 3 4 5 6 7 |
function customposttype_image_box() { remove_meta_box('postimagediv', 'home-page-banners', 'side'); remove_meta_box('postimagediv', 'page', 'side'); add_meta_box('postimagediv', __('Banner Image - The image that appears at the top of the page, size should be 760 x 155 pixels'), 'post_thumbnail_meta_box', 'page', 'normal', 'high'); add_meta_box('postimagediv', __('Banner Image - 760 x 390 pixels - Bigger images will be cropped automatically.'), 'post_thumbnail_meta_box', 'home-page-banners', 'normal', 'high'); } add_action('do_meta_boxes', 'customposttype_image_box'); |
Snippet Source/Credit: WordPress.org
How To Remove Default Author Profile Fields In WordPress
With the help of following snippet, you will be able to remove default author profile fields in WordPress.
1 2 3 4 5 6 7 |
add_filter('user_contactmethods','hide_profile_fields',10,1); function hide_profile_fields( $contactmethods ) { unset($contactmethods['aim']); unset($contactmethods['jabber']); unset($contactmethods['yim']); return $contactmethods; } |
Snippet Source/Credit: Snipplr
How To Use LESS In WordPress
With the help of following snippet, you will be able to use LESS in WordPress.
1 2 3 4 5 6 7 8 9 |
/** START - ADD LESS TO WORDPRESS - http://eckstein.id.au **/ add_action( 'wp_head' , 'itsb_lesscss' ); function itsb_lesscss() { ?> <link rel="stylesheet/less" type="text/css" href="<?php echo bloginfo('url'); ?>/wp-content/mu-plugins/style.less"> <script src="//cdnjs.cloudflare.com/ajax/libs/less.js/1.3.0/less-1.3.0.min.js" type="text/javascript"></script> <?php } /** END - ADD LESS TO WORDPRESS **/ |
Snippet Source/Credit: eckstein.id.au