What WordPress Loop Hacks Can Be Done Without Plugins

Thanks to WordPress and its extravagant features that empower developers to simplify the process of development. Featuring 38000+ free plugins and ‘n’ number of custom and premium plugins, WordPress has a plugin for every business need and functionality. Though plugins are appreciated for enabling a specific feature on a website, however there are many other features that can be installed in a WordPress site without requiring the usage of plugins.
This blog shares a list of best WordPress snippets that can be made use of without requiring a plugin.

Replacing the existing login logo with the original one

This is entirely related to the branding. If you wish to modify the WordPress site logo on login page with either the client or your one, then you need coding for that. It is quite simple: Open functions.php and enter the following code:

function my_custom_login_logo() {
    echo ‘<style type=”text/css”>
        h1 a { background-image:url(‘.get_bloginfo(‘template_directory’).’/images/custom-login-logo.gif) !important; }
add_action(‘login_head’, ‘my_custom_login_logo’);

This is the initial step to encourage/strengthen your brand with just a single tweak.

If you wish to modify the feel of WordPress admin and make it unique to your business goal, just paste this coding:

function custom_admin_logo() {
  echo ‘<style type=”text/css”>
          #header-logo { background-image: url(‘.get_bloginfo(‘template_directory’).’/images/admin_logo.png) !important; }
add_action(‘admin_head’, ‘custom_admin_logo’);

After entering this, just display your logo in wp-images folder via admin_logo.png

Disabling login hints

Website security is the priority, be it WordPress or any other. To maintain the same, it is important not to provide any sort of detailed error message on WordPress login . Disable such error messages by applying the following coding:
On functions.php, copy:

function no_wordpress_errors(){
  return ‘GET OFF MY LAWN !! RIGHT NOW !!’;
add_filter( ‘login_errors’, ‘no_wordpress_errors’ );

This way you can be saved from not providing useful hints that can be used by hackers for any kind of malicious activity.

Keeping WordPress panel active for a longer duration

While working on public wi fi, it is always advisable to exit from such devices. However, if you are using your personal PC, getting logged out again and again might sound frustrating at times. However, with this WordPress tweak you can easily extend the duration of WordPress login session. The code given below will definitely do wonders
Open functions.php and write:

add_filter( ‘auth_cookie_expiration’, ‘stay_logged_in_for_1_year’ );
function stay_logged_in_for_1_year( $expire ) {
  return 31556926; // 1 year in seconds

With this code, WordPress will keep you active for like 2 weeks while assessing the “Remember Me” option at the login. Similarly, the expiry date of authorization login cookie can be set by replacing “31556926” with the preferred time duration.

A unique and brand-focused messaging builds up your brand. So, it is important to add tagline or some other cool text on the footer of WordPress dashboard. Instead of just having the logo, the text on footer section should also add to the brand credibility.
For changing the footer text, use below-given code:

function remove_footer_admin () {
  echo “Your own text”;
add_filter(‘admin_footer_text’, ‘remove_footer_admin’);

Make your posts stand out by featuring them with images

In order to stand out from the crowd, it is recommended to publish such posts that are filled with product images, news, etc. Using this coding, you can make it necessary for your users to insert a featured image while publishing.

add_action(‘save_post’, ‘wpds_check_thumbnail’);
add_action(‘admin_notices’, ‘wpds_thumbnail_error’);
function wpds_check_thumbnail( $post_id ) {
  // change to any custom post type
  if( get_post_type($post_id) != ‘post’ )
  if ( ! has_post_thumbnail( $post_id ) ) {
    // set a transient to show the users an admin message
    set_transient( “has_post_thumbnail”, “no” );
    // unhook this function so it doesn’t loop infinitely
    remove_action(‘save_post’, ‘wpds_check_thumbnail’);
    // update the post set it to draft
    wp_update_post(array(‘ID’ => $post_id, ‘post_status’ => ‘draft’));
    add_action(‘save_post’, ‘wpds_check_thumbnail’);
  } else {
    delete_transient( “has_post_thumbnail” );
function wpds_thumbnail_error() {
  // check if the transient is set, and display the error message
  if ( get_transient( “has_post_thumbnail” ) == “no” ) {
    echo “<div id=’message’ class=’error’><p><strong></strong></p></div>”;
    delete_transient( “has_post_thumbnail” );

Reduce post editing

WordPress does not sets any limit to the edition of posts available in the database. However, it does not look wise to set infinite number of post revisions to be saved for the future. With the help of this WordPress tweak, you will be able to disable the storage of posts revised or edited.
Open wp-config.php file and insert:

define( ‘WP_POST_REVISIONS’, 3 );

In the number of “WP_POST_REVISIONS’, 3”, you need to enter the number.

Wrapping it Up:

So, these are some basic yet useful tweaks that can be performed in your WordPress website. The list doesn’t end here, however if you find any of them useful, please check it on your WordPress website. Let us know for any other queries.