Code & Me
WordPress Code Snippet Repository
  • Home
  • Featured
  • Recently Added
  • About
  • Contact

Cleaning Up Wp_head() Without Using Any Plugin

March 26, 2014 By Editorial Staff in WordPress No Comments Tags: Cleaning Up, Code Snippet, Snippet, WordPress, WordPress Snippet, WP Head

WordPress does adds a lot of stuff via wp_head() hook while some of this is useful in nature while others not. For cleaning up the wp_head() easily, simply add the following snippet and you are done while the plus point is that you need not require any plugin for the same.

1
2
3
4
5
6
7
remove_action( 'wp_head', 'rsd_link' );
remove_action( 'wp_head', 'wlwmanifest_link' );
remove_action( 'wp_head', 'wp_generator' );
remove_action( 'wp_head', 'start_post_rel_link' );
remove_action( 'wp_head', 'index_rel_link' );
remove_action( 'wp_head', 'adjacent_posts_rel_link' );
remove_action( 'wp_head', 'wp_shortlink_wp_head' );

Snippet Source/Credit: Noumaan Yaqoob

How To Remove Widgets From WordPress Dashboard

March 25, 2014 By Editorial Staff in Featured, WordPress No Comments Tags: Code Snippet, Dashboard, Widget, Widgets, WordPress, WordPress Dashboard, WordPress Snippet

It often come a situation in front of you when you drastically want to remove widgets from your WordPress dashboard. Simply paste the following snippet in your theme’s functions.php file and you will be able to accomplish the task.

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 Add A Custom Message To The Editor Pane

By Editorial Staff in WordPress No Comments Tags: Code Snippet, Custom Message, Editor Pane, Snippet, WordPress, WordPress Snippet

If you are building a website for a non-techy person, then it will be good to add a custom message to the editor pane. Doing this will add more value to the end user’s pace while this can be achieved simply by copying the following snippet in your theme’s functions.php file.

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 Load All Posts From The Current Week

March 24, 2014 By Editorial Staff in Featured, WordPress No Comments Tags: Current Week, Post, Snippet, WordPress, WordPress Snippet

Your website visitors often asked you that they will be interested in viewing all the posts from the current week all together. While the idea to load all posts sounds really good BUT it can be done only if you got the right snippet in hand. Using the following snippet and you will be able to load 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

Changing WordPress Login Logo Title Attribute

By Editorial Staff in WordPress No Comments Tags: Login, Login Logo, Snippet, WordPress, WordPress login logo, WordPress Snippet

On simply pasting the following snippet into your theme’s functions.php file, 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 Redirect To A Custom Page After Registration

March 21, 2014 By Editorial Staff in Featured, WordPress No Comments Tags: Custom Page, Redirect, Registration, Shortcode, Snippet, WordPress Shortcode, WordPress Snippets

The following snippet will let you redirect to a custom page once registration got completed. Simply copy the snippet and paste it to your theme’s functions.php file.

1
2
3
4
function __my_registration_redirect(){
    return home_url( '/my-page' );
}
add_filter( 'registration_redirect', '__my_registration_redirect' );

Snippet Source/Credit: TheDeadMedic

WordPress Change Author URL Base

By Editorial Staff in Featured, WordPress No Comments Tags: Author, Author URL, Shortcode, Snippet, URL, URL Base, WordPress Shortcode, WordPress Snippets

By default, author profiles are accessible using the pre-defined slug yourwebsite.com/author/name. What if there will be a case when you want to use the term “author-profile” or any other instead of just “author” in the URL. Pasting the following code in your theme’s functions.php file will change author URL base. Remember to replace profile on line 4 by any slug you like.

1
2
3
4
5
6
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;
}

Snippet Source/Credit: Kevin Chard

Adding Gravatars For The Post Author

By Editorial Staff in WordPress No Comments Tags: Gravatar, Shortcode, Snippet, WordPress Post, WordPress Shortcode, WordPress Snippets

Simply paste the following snippet and you will be able to automatically add the author gravatars to each post.

1
<?php echo get_avatar( get_the_author_email(), '80' ); ?>

Snippet Source/Credit: emoticode

How To Paginate Your WordPress Site Like Dribbble

March 20, 2014 By Editorial Staff in WordPress No Comments Tags: Dribbble, Paginate, Snippet, WordPress, WordPress Site, WordPress Snippet

If you love dribbble, then without a doubt you love to see the Dribbble everywhere. While for everywhere I can’t say currently BUT I am sure using the following snippet will let you paginate your WordPress site like Dribbble. Want it? Simply paste the following snippet to your theme’s single.php file at the place where you want to display the dribbble-like pagination.

1
2
3
4
5
6
7
8
9
10
11
12
13
<?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>

Snippet Source/Credit: Elliott Richmond

How To Load jQuery From Google CDN

By Editorial Staff in WordPress No Comments Tags: CDN, Content Delivery Network, Google CDN, jQuery, Snippet, WordPress, WordPress Snippet

WordPress by default load its own jQuery in your theme BUT using the following snippet in your theme’s functions.php file will load the library directly from Google CDN.

1
2
3
4
5
6
7
8
function jquery_cdn() {
   if (!is_admin()) {
      wp_deregister_script('jquery');
      wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js', false, '1.8.3');
      wp_enqueue_script('jquery');
   }
}
add_action('init', 'jquery_cdn');

Snippet Source/Credit: WP Tips

«< 64 65 66 67 68 >

Recently Added Snippets

  • How To Set Role And Capabilities In WordPress
  • How To Set WordPress Options As Value
  • List Author Comments On Author Page
  • WordPress Display Page
  • Removing WordPress Version From Head And Feeds

Search The Snippet

Featured Snippets

  • How To Set WordPress Options As Value
  • WordPress Display Page
  • Removing WordPress Version From Head And Feeds
  • Delete Link In Comments In Your WordPress Website
  • Creating Database For Your WordPress Website
Code & Me
  • About
  • Recently Added
  • Advertise
  • Terms
  • Privacy Policy
  • Contact
© 2014-19 CodeAndMe.
Proud Member Of G2One Network Family.

↑ Back to top