All WordPress themes come with powerful functions.php file. This file act as a plugin and allows you to do lots of cool things on your WordPress site. In the following article, we will show you some of the most useful tricks for your WordPress functions file.

What is WordPress functions file?

The objective of this WordPress functions file is to permit theme builders to outline theme options and featrues. This file acts identical to a wordpress plugin and can be utilized so as to add your individual code snippets in wordpress.

You would discover many of those code snippets on web sites like WordPress Tutorials Adv. With instructions telling you so as to add this code in your theme’s fetures.php file or a site-specific WordPress plugin.

Site-Specific plugin or features.php file???

Which one is best?

A site-specific plugin is significantly better , while features.php file is extra handy. Simply as a result of it’s unbiased of your WordPress theme and would work no matter which theme you might be utilizing.

Having started that, listed below are some extraordinarily helpful tips for the WordPress features file.

 

  1. Remove WordPress Version Number.

You should always use the latest version of WordPress. However, you may still want to remove the WordPress version number from your site. Simply add this code snippet to your WordPress functions file.

             function tcz_remove_version() {

             return ”;

             }

             add_filter(‘the_generator’, ‘tcz_remove_version’);

 

  1. Add A Custom Dashboard Logo

If you Want to white label your WordPress admin area, the first step is to add a custm dashboard logo.

First you will need to upload your custom logo to your theme’s images folder as custim-logo.php. Make sure your custom logo is 16*16 pixel in size.

After that add the following code to your theme’s WordPress functions file.

                  function tcz_custom_logo() {

                  echo ‘

                 <style type=”text/css”>

                 #wpadminbar #wp-admin-bar-wp-logo > .ab-item .ab-icon:before {

                  background-image: url(‘ . get_bloginfo(‘stylesheet_directory’) . ‘/images/custom-logo.png) !important;

                 background-position: 0 0;

                 color:rgba(0, 0, 0, 0);

 }

                #wpadminbar #wp-admin-bar-wp-logo.hover > .ab-item .ab-icon {

               background-position: 0 0;

              }

              </style>’;

              }//hook into the administrative header output

              add_action(‘wp_before_admin_bar_render’, ‘tcz_custom_logo’);

 

  1. Change the footer in WordPress Admin Panel

The footer in WordPress admin area shows the message

“ Thank you for creating with WordPress” .

You can change it to anything you want by adding this code.

function remove_footer_admin () {

echo 'Fueled by <a href="http://www.wordpress.org" target="_blank">WordPress</a> | WordPress Tutorials: <a href="http://www.onlineshouter.com" target="_blank">onlineshouter</a></p>';

}

add_filter('admin_footer_text', 'remove_footer_admin');

  1. Dynamic Copyright Data in WordPress Footer

You can merely add copyright date by modifying the footer template in you theme. However, it will not present when your website began and it will not robotically change subsequent yr.

To add a dynamic copyright date in WordPress footer, you can use the code below,

operate wpb_copyright()

After that, open your footer.php file and then add the following code in the place where you wish to show the dynamic copyright date:

<?php echo wpb_copyright(); ?>

This operate seems for the date of your first submit, and the date of your final submit. It after that echos the years wherever you name the operate.

 

  1. Update WordPress URLs

If your wordpress login page keeps refreshing or you are unable to access admin area, then you need to update WordPress URLs.

One way to do this is by using wp-config.php file. However, if you do that you will not be able to set correct address on the settings page.After that The WordPress URL and site URL fields will be locked and uneditable.

If you want to fix this problem, then you should add the following code to your function file.

update_option( ‘siteurl’, ‘http://example.com’ );

update_option( ‘home’, ‘http://example.com’ );

After that Remember to repelace example.com with you own doamin name.

Once you are logged in, you can go to settings and set the URLs there. After that you should remvoe the code you added to the functions file, otherwise it will keep updating those URLs any time your ite is accessed.

 

  1. Disable login by Email in WordPress

WordPress permits customers to login with username or e-mail tackle. You can simply disable login by e-mail in WordPress by including this code to your WordPress features file.

remove_filter( ‘authenticate’, ‘wp_authenticate_email_password’, 20 );

  1. Show total number of registered users in WordPress

Do you want to show a total number of registered users on your WordPress site? Simply add the following code to your theme’s WordPress functions file.

                                 // Function to return user count

		function wpb_user_count() { 
		$usercount = count_users();
		$result = $usercount['total_users']; 
		return $result; 
		} 
		// Creating a shortcode to display user count
		add_shortcode('user_count', 'wpb_user_count');

After that This code will create a shortcode and it will display a total number of registered users on your site. Now you just need to add this shortcode to [user_count] you post or page where you want to show the total number pf users.

 

 

  1. Disable XML-RPC in WordPress

XML-RPC is a method that allows third party apps to communicate with you WordPress site remotely. This could cause security issues and can be exploited by hackers.

Finally Simply add the following code to your WordPress functions file to turn off XML_RPC in WordPress:

add_filter(‘xmlrpc_enabled’, ‘__return_false’);

 

  1. Manipulates RSS feed footer

Have you seen blogs that provides their commercial of their RSS feeds beneath every submit. You can accomplish that simply with a easy operate.  After that Paste the following code:

 operate wpbeginner_postrss($content material)   add_filter('the_excerpt_rss', 'wpbeginner_postrss'); add_filter('the_content', 'wpbeginner_postrss');  

 

  1. Delay posts in RSS feed

Sometimes it’s possible you will find yourself with a grammar or spelling mistake in your article. The mistake goes dwell and is distributed to your RSS feed subscribes. If you could have e-mail subscriptions in your WordPress weblog, then these subscribers will get it as effectively.

After that Simply add this code in our theme’s functions file.

 

        function publish_later_on_feed($where) {

        global $wpdb;

        if ( is_feed() ) {
        // timestamp in WP-format
        $now = gmdate('Y-m-d H:i:s');

        // value for wait; + device
        $wait = '10'; // integer

        // http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_timestampdiff
        $device = 'MINUTE'; //MINUTE, HOUR, DAY, WEEK, MONTH, YEAR

        // add SQL-sytax to default $where
        $where .= " AND TIMESTAMPDIFF($device, $wpdb->posts.post_date_gmt, '$now') > $wait ";
        }
        return $where;
        }

        add_filter('posts_where', 'publish_later_on_feed');




We hope this text helped you study some new helpful tips for features.php file in WordPress. 
After that You may additionally need to see our final information to spice up WordPress velocity and efficiency.

Leave a Reply

Your email address will not be published. Required fields are marked *