Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

46 Extremely Useful Tricks for the WordPress Functions File

The WordPress functions file, known as functions.php, is a powerful tool that comes with every WordPress theme. It acts like a plugin, allowing you to add custom code to your site with ease.

We use custom code on our sites when a short piece of code can be used. This versatility and flexibility in WordPress allow us to combine the functionality of several plugins in an easy-to-manage way.

In this article, we’ll share some of those practical and useful tricks for using your WordPress functions file, helping you get more out of your WordPress site.

Handy WordPress functions file tips and hacks

What Is the Functions File in WordPress?

The functions.php file is a WordPress theme file that comes with all free and premium WordPress themes.

It acts as a plugin and allows theme developers to define theme features. Users can also use it to add their custom code snippets in WordPress.

However, saving custom code in functions file is not a good practise.

If you update your theme, the functions.php file will be overwritten, and you will lose your custom code snippets. You cannot turn off a snippet without deleting it.

Instead, we recommend everyone use WPCode, a free plugin that lets you insert code snippets into your WordPress website without editing any theme, plugin, or core WordPress files.

Why do we recommend WPCode?

  • Easily save custom code snippets without editing any core files.
  • Automatically insert code snippets where you need them
  • Each code snippet is saved separately and can be turned off individually.
  • A built-in fail-safe mechanism will deactivate a code snippet if it causes an error on your site.

As a bonus, the WPCode plugin has an extensive library of pre-configured code snippets (including many on this list). You can deploy these code snippets with a few clicks.

wpcode library

Having said that, here is a list of items we will cover in this article. You can jump to one that interests you or simply follow along:

How to Add These Code Snippets to Your Website

Before we begin, let’s look at how to add the code snippets in this article to your WordPress functions file.

1. Add Custom Code to Functions File Using WPCode (Recommended)

First, you need to install and activate the WPCode plugin. For more details, see our step-by-step guide on how to install a WordPress plugin.

Upon activation, go to Code Snippets » + Add Snippet page. You’ll see WPCode’s code library with many helpful custom code snippets already added.

Add snippet

If your code snippet does the same thing as the snippets in the library, then you can try out the one already added there.

Alternatively, click the ‘blank snippet’ link to continue adding your custom code snippet.

On the next screen, provide a title for your custom code. This could be anything that helps you identify what this code snippet does.

Adding your custom code

Next, you need to choose the ‘Code Type’. If you are adding a code that works in the functions.php file, then you must select ‘PHP Snippet.’

Below that, you need to copy and paste your custom code into the ‘Code Preview’ box.

Finally, you need to set your snippet as ‘Active’ and click the ‘Save Snippet’ button.

Activate and save

Your saved snippet will now run like it would if you had added it to the functions.php file.

You can repeat the process to add more snippets when needed. You can also deactivate a snippet without deleting it.

2. Add Custom Code Directly to the Functions File

The WPCode method is always better than adding code to the theme’s functions file.

However, some users may be writing code for a client’s custom WordPress theme or simply prefer to add code to the functions.php file.

In that case, here is how you can add code to your WordPress theme’s functions.php file.

First, connect to your WordPress website using an FTP client. Once connected, navigate to the /wp-content/themes/your-wordpress-theme/ folder.

Edit functions.php file

There you will find the functions.php file. Simply right-click and select to edit or download the file to your computer for editing.

You can edit it using any plain text editor like Notepad or TextEdit.

Then, scroll down to the bottom of the functions.php file and paste your code snippet there. You can save your changes and upload the updated functions.php file to your theme folder.

You can now visit your WordPress website to see your custom code in action.

Now, let’s take a look at 46 different useful tricks for the WordPress functions file.

1. Remove WordPress Version Number

You should always use the latest version of WordPress. However, you may want to remove the WordPress version number from your site.

Simply add this code snippet to your functions file or as a new WPCode snippet:

function wpb_remove_version() {
return '';
}
add_filter('the_generator', 'wpb_remove_version');

For detailed instructions, see our guide on the right way to remove the WordPress version number.

Want to white-label your WordPress admin area? The first step is to add a custom dashboard logo.

First, you’ll need to upload your custom logo to your theme’s images folder as custom-logo.png. Your custom logo should be in a 1:1 ratio (a square image) in 16×16 pixels.

After that, you can add this code to your theme’s functions file or as a new WPCode snippet:

function wpb_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', 'wpb_custom_logo');

For more details, see our guide on how to add a custom dashboard logo in WordPress.

3. Change the Footer in The WordPress Admin Panel

The footer in the 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="https://www.wpbeginner.com" target="_blank">WPBeginner</a></p>';

}

add_filter('admin_footer_text', 'remove_footer_admin');

Feel free to change the text and links that you want to add. Here is how it looks on our test site.

Admin footer

4. Add Custom Dashboard Widgets in WordPress

You probably have seen the widgets that many plugins and themes add to the WordPress dashboard. You can add one yourself by pasting the following code:

add_action('wp_dashboard_setup', 'my_custom_dashboard_widgets');

function my_custom_dashboard_widgets() {
global $wp_meta_boxes;

wp_add_dashboard_widget('custom_help_widget', 'Theme Support', 'custom_dashboard_help');
}

function custom_dashboard_help() {
echo '<p>Welcome to Custom Blog Theme! Need help? Contact the developer <a href="mailto:yourusername@gmail.com">here</a>. For WordPress Tutorials visit: <a href="https://www.wpbeginner.com" target="_blank">WPBeginner</a></p>';
}

This is what it would look like:

Custom dashboard widget

For details, see our tutorial on how to add custom dashboard widgets in WordPress.

5. Change the Default Gravatar in WordPress

Have you seen the default mystery man avatar on blogs? You can easily replace it with your own branded custom avatar.

Simply upload the image you want to use as the default avatar and add this code to your functions file or the WPCode plugin:

function wpb_custom_default_gravatar( $avatar_defaults ) {
	$myavatar = 'https://example.com/wp-content/uploads/2022/10/dummygravatar.png';
	$avatar_defaults[$myavatar] = 'Default Gravatar';
	return $avatar_defaults;
}
add_filter( 'avatar_defaults', 'wpb_custom_default_gravatar' );

Now you can head to the Settings » Discussion page and select your default avatar.

Custom default gravatar

For detailed instructions, see our guide on changing the default gravatar in WordPress.

6. Dynamic Copyright Date in WordPress Footer

You can simply add a copyright date by editing the footer template in your theme. However, it will not show when your site started, and it will not automatically change the following year.

This code can add a dynamic copyright date in the WordPress footer:

function wpb_copyright() {
global $wpdb;
$copyright_dates = $wpdb->get_results("
SELECT
YEAR(min(post_date_gmt)) AS firstdate,
YEAR(max(post_date_gmt)) AS lastdate
FROM
$wpdb->posts
WHERE
post_status = 'publish'
");
$output = '';
if($copyright_dates) {
$copyright = "© " . $copyright_dates[0]->firstdate;
if($copyright_dates[0]->firstdate != $copyright_dates[0]->lastdate) {
$copyright .= '-' . $copyright_dates[0]->lastdate;
}
$output = $copyright;
}
return $output;
}

After adding this function, you’ll need to open your footer.php file and add the following code where you would like to display the dynamic copyright date:

<?php echo wpb_copyright(); ?>

This function looks for the date of your first post and the date of your last post. It then returns the years wherever you call the function.

Tip: If you are using the WPCode plugin, then you can combine the two code snippets. After that, choose the ‘Site Wide Footer’ location in the ‘Insertion’ section of the snippet settings. This will automatically display the copyright date in the footer without editing your theme’s footer.php file.

Add to footer using WPCode

For more details, see our guide on how to add dynamic copyright dates in WordPress.

7. Randomly Change the Background Color in WordPress

Do you want to randomly change the background color on your WordPress blog for each visit and page reload? Here is how to do this easily.

First, add this code to your theme’s functions file or the WPCode plugin:

function wpb_bg() {
$rand = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f');
$color ='#'.$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].
$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)];

echo $color; 
} 

Next, you’ll need to edit the header.php file in your theme. Find the <body> tag and replace it with this line:

<body <?php body_class(); ?> style="background-color:<?php wpb_bg();?>">

You can now save your changes and visit your website to see this code in action.

Random background colors

For more details and alternate methods, see our tutorial on randomly changing the background color in WordPress.

8. Update WordPress URLs

If your WordPress login page keeps refreshing or you cannot access the admin area, then you need to update WordPress URLs.

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

Instead, just add this code to your functions file to fix this:

update_option( 'siteurl', 'https://example.com' );
update_option( 'home', 'https://example.com' );

Don’t forget to replace example.com with your domain name.

Once logged in, you can go to the Settings page in the WordPress admin area and set the URLs.

After that, you should remove the code you added to the functions file or WPCode. Otherwise, it will keep updating those URLs whenever your site is accessed.

9. Add Additional Image Sizes in WordPress

WordPress automatically generates several image sizes when you upload an image. You can also create additional image sizes to use in your theme.

Simply add this code to your theme’s functions file or as a WPCode snippet:

add_image_size( 'sidebar-thumb', 120, 120, true ); // Hard Crop Mode
add_image_size( 'homepage-thumb', 220, 180 ); // Soft Crop Mode
add_image_size( 'singlepost-thumb', 590, 9999 ); // Unlimited Height Mode

This code creates three new image sizes of different sizes. Feel free to tweak the code to meet your requirements.

You can then display an image size anywhere in your theme using this code:

<?php the_post_thumbnail( 'homepage-thumb' ); ?>

For detailed instructions, see our guide on creating additional image sizes in WordPress.

10. Add New Navigation Menus to Your Theme

WordPress allows theme developers to define navigation menus and then display them.

You can add this code to your theme’s functions file or as a new WPCode snippet to define a new menu location in your theme:

function wpb_custom_new_menu() {
  register_nav_menu('my-custom-menu',__( 'My Custom Menu' ));
}
add_action( 'init', 'wpb_custom_new_menu' );

You can now go to Appearance » Menus in your WordPress dashboard and see ‘My Custom Menu’ as the theme location option.

Custom menu location

Note: This code will also work with block themes with the full site editing feature. Adding it will enable the Menus screen under Appearance.

Now you need to add this code to your theme where you want to display the navigation menu:

 <?php
wp_nav_menu( array( 
    'theme_location' => 'my-custom-menu', 
    'container_class' => 'custom-menu-class' ) ); 
?>

For detailed instructions, see our guide on how to add custom navigation menus in WordPress themes.

11. Add Author Profile Fields

Do you want to add extra fields to your author profiles in WordPress? You can easily do that by adding this code to your functions file or as a new WPCode snippet:

function wpb_new_contactmethods( $contactmethods ) {
// Add Twitter
$contactmethods['twitter'] = 'Twitter';
//add Facebook
$contactmethods['facebook'] = 'Facebook';

return $contactmethods;
}
add_filter('user_contactmethods','wpb_new_contactmethods',10,1);

This code will add Twitter and Facebook fields to user profiles in WordPress.

New profile fields

You can now display these fields in your author template like this:

<?php echo get_the_author_meta('twitter') ?>

You may also want to see our guide on adding additional user profile fields in WordPress registration.

12. Adding Widget-Ready Areas or Sidebars in WordPress Themes

This is one of the most used code snippets, and many developers already know about adding widget-ready areas or sidebars to WordPress themes. But it deserves to be on this list for those people who don’t know.

You can paste the following code in your functions.php file or as a new WPCode snippet:

// Register Sidebars
function custom_sidebars() {

	$args = array(
		'id'            => 'custom_sidebar',
		'name'          => __( 'Custom Widget Area', 'text_domain' ),
		'description'   => __( 'A custom widget area', 'text_domain' ),
		'before_title'  => '<h3 class="widget-title">',
		'after_title'   => '</h3>',
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  => '</aside>',
	);
	register_sidebar( $args );

}
add_action( 'widgets_init', 'custom_sidebars' );

Note: This code will also work with block themes with the full site editing feature. Adding it will enable the Widgets screen under Appearance.

You can now visit the Appearance » Widgets page and see your new custom widget area.

Custom widget area

To display this sidebar or widget-ready area on your website, you’ll need to add the following code in the template where you want to display it:

<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('custom_sidebar') ) : ?>
<!–Default sidebar info goes here–>
<?php endif; ?>

For more details, see our guide on how to add dynamic widget-ready areas and sidebars in WordPress.

13. Manipulate the RSS Feed Footer

Have you seen blogs that add their advertisements in their RSS feeds below each post? You can accomplish this easily with a simple function. Just paste the following code:

function wpbeginner_postrss($content) {
if(is_feed()){
$content = 'This post was written by Syed Balkhi '.$content.'Check out WPBeginner';
}
return $content;
}
add_filter('the_excerpt_rss', 'wpbeginner_postrss');
add_filter('the_content', 'wpbeginner_postrss');

For more information, see our guide on how to add content and completely manipulate your RSS feeds.

14. Add Featured Images to RSS Feeds

The post thumbnail or featured images are usually only displayed within your site design. You can easily extend that functionality to your RSS feed with the following code:

function rss_post_thumbnail($content) {
global $post;
if(has_post_thumbnail($post->ID)) {
$content = '<p>' . get_the_post_thumbnail($post->ID) .
'</p>' . get_the_content();
}
return $content;
}
add_filter('the_excerpt_rss', 'rss_post_thumbnail');
add_filter('the_content_feed', 'rss_post_thumbnail');

For more details, see our guide on how to add post thumbnails to your WordPress RSS feed.

15. Hide Login Errors in WordPress

Hackers can use login errors to guess whether they entered the wrong username or password. By hiding login errors in WordPress, you can make your login area and WordPress website more secure.

Simply add the following code to your theme’s functions file or as a new WPCode snippet:

function no_wordpress_errors(){
  return 'Something is wrong!';
}
add_filter( 'login_errors', 'no_wordpress_errors' );

Now, users will see a generic message when they enter an incorrect username or password.

Custom login errors

For more information, see our tutorial on disabling login hints in WordPress error messages.

16. Disable Login by Email in WordPress

WordPress allows users to log in with their username or email address. You can easily disable login by email in WordPress by adding this code to your functions file or as a new WPCode snippet:

remove_filter( 'authenticate', 'wp_authenticate_email_password', 20 );

For more information, see our guide on how to disable login by email feature in WordPress.

17. Disable The Search Feature in WordPress

If you want to disable your WordPress site’s search feature, simply add this code to your functions file or in a new WPCode snippet:

function wpb_filter_query( $query, $error = true ) {
if ( is_search() ) {
$query->is_search = false;
$query->query_vars[s] = false;
$query->query[s] = false;
if ( $error == true )
$query->is_404 = true;
}}

This code simply disables the search query by modifying it and returning a 404 error instead of search results.

For more information, see our tutorial on disabling the WordPress search feature.

Pro Tip: Instead of giving up on WordPress search, we recommend trying out SearchWP. It is the best WordPress search plugin on the market that allows you to add a powerful and customizable search feature to your website.

18. Delay Posts in RSS Feed

Sometimes, you may publish an article with a grammatical error or spelling mistake.

The mistake goes live and is distributed to your RSS feed subscribers. If you have email subscriptions on your WordPress blog, then those subscribers will also get a notification.

Simply add this code to your theme’s functions file or as a new WPCode snippet to delay posts in your RSS feed:

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');

In this code, we used 10 minutes as $wait or delay time. Feel free to change this to any number of minutes you want.

For a plugin method and more information, see our detailed guide on how to delay posts from appearing in the WordPress RSS feed.

19. Change Read More Text for Excerpts in WordPress

Do you want to change the text that appears after the excerpt in your posts? Simply add this code to your theme’s functions file or as a new WPCode snippet:

function modify_read_more_link() {
    return '<a class="more-link" href="' . get_permalink() . '">Your Read More Link Text</a>';
}
add_filter( 'the_content_more_link', 'modify_read_more_link' );

20. Disable RSS Feeds in WordPress

Not all websites need RSS feeds. If you want to disable RSS feeds on your WordPress site, then add this code to your theme’s functions file or as a new WPCode snippet:

function new_excerpt_more($more) {
 global $post;
 return '<a class="moretag" 
 href="'. get_permalink($post->ID) . '">Your Read More Link Text</a>';
}
add_filter('excerpt_more', 'new_excerpt_more');

For more information on a plugin method, see our guide on how to disable RSS feeds in WordPress.

21. Change Excerpt Length in WordPress

WordPress limits excerpt lengths to 55 words. You can add this code to your functions file or as a new WPCode snippet if you need to change that:

function new_excerpt_length($length) {
return 100;
}
add_filter('excerpt_length', 'new_excerpt_length');

Just change 100 to the number of words you want to show in the excerpts.

For alternate methods, you may want to look at our guide on how to customize WordPress excerpts (no coding required).

22. Add an Admin User in WordPress

If you have forgotten your WordPress password and email, then you can add an admin user by adding this code to your theme’s functions file using an FTP client:

function wpb_admin_account(){
$user = 'Username';
$pass = 'Password';
$email = 'email@domain.com';
if ( !username_exists( $user )  && !email_exists( $email ) ) {
$user_id = wp_create_user( $user, $pass, $email );
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
} }
add_action('init','wpb_admin_account');

Don’t forget to fill in the username, password, and email fields.

Important: Once you log in to your WordPress site, don’t forget to delete the code from your functions file.

For more on this topic, take a look at our tutorial on how to add an admin user in WordPress using FTP.

23. Disable Language Switcher on Login Page

If you run a multilingual website, then WordPress displays a language selector on the login page. You can easily disable it by adding the following code to your functions.php file or as a new WPCode snippet:

add_filter( 'login_display_language_dropdown', '__return_false' );

24. Show the Total Number of Registered Users in WordPress

Do you want to show the total number of registered users on your WordPress site? Simply add this code to your theme’s functions file or as a new WPCode snippet:

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');

This code creates a shortcode that allows you to display the total number of registered users on your site.

Now, you just need to add the shortcode [user_count] to your post or page where you want to show the total number of users.

For more information and a plugin method, see our tutorial on how to display the total number of registered users in WordPress.

25. Exclude Specific Categories From RSS Feed

Do you want to exclude specific categories from your WordPress RSS feed? You can add this code to your theme’s functions file or as a new WPCode snippet:

function exclude_category($query) {
	if ( $query->is_feed ) {
		$query->set('cat', '-5, -2, -3');
	}
return $query;
}
add_filter('pre_get_posts', 'exclude_category');

26. Disable URL Links in WordPress Comments

By default, WordPress converts a URL into a clickable link in comments.

You can stop this by adding the following code to your functions file or as a new WPCode snippet:

remove_filter( 'comment_text', 'make_clickable', 9 );

For details, see our article on how to disable autolinking in WordPress comments.

27. Add Odd and Even CSS Classes to WordPress Posts

You may have seen WordPress themes using an odd or even class for WordPress comments. It helps users visualize where one comment ends and the next one begins.

You can use the same technique for your WordPress posts. It looks aesthetically pleasing and helps users quickly scan pages with lots of content.

Simply add this code to your theme’s functions file:

function oddeven_post_class ( $classes ) {
   global $current_class;
   $classes[] = $current_class;
   $current_class = ($current_class == 'odd') ? 'even' : 'odd';
   return $classes;
}
add_filter ( 'post_class' , 'oddeven_post_class' );
global $current_class;
$current_class = 'odd';

This code simply adds an odd or even class to WordPress posts. You can now add custom CSS to style them differently.

Here is some sample code to help you get started:

.even {
background:#f0f8ff;
}
.odd {
 background:#f4f4fb;
}

The end result will look something like this:

Alternating background colors

Need more detailed instructions? Take a look at our tutorial on how to add odd/even classes to your posts in WordPress themes.

28. Add Additional File Types to Be Uploaded in WordPress

By default, WordPress allows you to upload a limited number of the most commonly used file types. However, you can extend it to allow other file types.

Just add this code to your theme’s functions file:

function my_myme_types($mime_types){
    $mime_types['svg'] = 'image/svg+xml'; //Adding svg extension
    $mime_types['psd'] = 'image/vnd.adobe.photoshop'; //Adding photoshop files
    return $mime_types;
}
add_filter('upload_mimes', 'my_myme_types', 1, 1);

This code allows you to upload SVG and PSD files to WordPress.

You will need to find the mime types for the file types you want to allow and then use them in the code.

For more on this topic, check out our tutorial on how to add additional file types to be uploaded in WordPress.

WordPress uses a non-existent email address (wordpress@yourdomain.com) to send outgoing emails by default.

This email address could be flagged as spam by email service providers.

Using the WP Mail SMTP plugin is the proper way to fix this.

WP Mail SMTP

It fixes email deliverability issues and allows you to choose an actual email address to send your WordPress emails.

To learn more, see our guide on how to fix WordPress not sending email issue.

On the other hand, if you want to quickly change this to a real email address, then you can add the following code in your functions file or as a new WPCode snippet:

// Function to change email address
function wpb_sender_email( $original_email_address ) {
    return 'tim.smith@example.com';
}
 
// Function to change sender name
function wpb_sender_name( $original_email_from ) {
    return 'Tim Smith';
}
 
// Hooking up our functions to WordPress filters 
add_filter( 'wp_mail_from', 'wpb_sender_email' );
add_filter( 'wp_mail_from_name', 'wpb_sender_name' );

Don’t forget to replace the email address and name with your own information.

The problem with this method is that WordPress is still using the mail() function to send emails, and such emails are most likely to end up in spam.

For better alternatives, see our tutorial on how to change the sender name in outgoing WordPress emails.

30. Add an Author Info Box in WordPress Posts

If you run a multi-author site and want to showcase author bios at the end of your posts, then you can try this method.

Start by adding this code to your functions file or as a new WPCode snippet:

function wpb_author_info_box( $content ) {

global $post;

// Detect if it is a single post with a post author
if ( is_single() && isset( $post->post_author ) ) {

// Get author's display name
$display_name = get_the_author_meta( 'display_name', $post->post_author );

// If display name is not available then use nickname as display name
if ( empty( $display_name ) )
$display_name = get_the_author_meta( 'nickname', $post->post_author );

// Get author's biographical information or description
$user_description = get_the_author_meta( 'user_description', $post->post_author );

// Get author's website URL
$user_website = get_the_author_meta('url', $post->post_author);

// Get link to the author archive page
$user_posts = get_author_posts_url( get_the_author_meta( 'ID' , $post->post_author));
	
// Get User Gravatar
$user_gravatar =  get_avatar( get_the_author_meta( 'ID' , $post->post_author) , 90 );

if ( ! empty( $display_name ) )

$author_details = '<p class="author_name">About ' . $display_name . '</p>';

if ( ! empty( $user_description ) )
// Author avatar and bio will be displayed if author has filled in description. 

$author_details .= '<p class="author_details">' . $user_gravatar . nl2br( $user_description ). '</p>';

$author_details .= '<p class="author_links"><a href="'. $user_posts .'">View all posts by ' . $display_name . '</a>';  

// Check if author has a website in their profile
if ( ! empty( $user_website ) ) {

// Display author website link
$author_details .= ' | <a href="' . $user_website .'" target="_blank" rel="nofollow noopener">Website</a></p>';

} else {
// if there is no author website then just close the paragraph
$author_details .= '</p>';
}

// Pass all this info to post content
$content = $content . '<footer class="author_bio_section" >' . $author_details . '</footer>';
}
return $content;
}

// Add our function to the post content filter
add_action( 'the_content', 'wpb_author_info_box' );

// Allow HTML in author bio section
remove_filter('pre_user_description', 'wp_filter_kses');

Next, you will need to add some custom CSS to make it look better.

You can use this sample CSS as a starting point:

.author_bio_section{
background: none repeat scroll 0 0 #F5F5F5;
padding: 15px;
border: 1px solid #ccc;
}

.author_name{
font-size:16px;
font-weight: bold;
}

.author_details img {
border: 1px solid #D8D8D8;
border-radius: 50%;
float: left;
margin: 0 10px 10px 0;
}

This is how your author box will look like:

Author bio box

For a plugin method and more detailed instructions, check out our article on how to add an author info box in WordPress posts.

31. Disable XML-RPC in WordPress

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

To turn off XML-RPC in WordPress, add the following code to your functions file or as a new WPCode snippet:

add_filter('xmlrpc_enabled', '__return_false');

You may want to read our article on how to disable XML-RPC in WordPress for more information.

32. Automatically Link Featured Images to Posts

If your WordPress theme does not automatically link featured images to full articles, then you can try this method.

Simply add this code to your theme’s functions file or as a new WPCode snippet:

function wpb_autolink_featured_images( $html, $post_id, $post_image_id ) {

If (! is_singular()) { 

$html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_the_title( $post_id ) ) . '">' . $html . '</a>';
return $html;

} else { 

return $html;

}

}
add_filter( 'post_thumbnail_html', 'wpb_autolink_featured_images', 10, 3 );

You may want to read our article on how to automatically link featured images to posts in WordPress.

33. Disable Block Editor in WordPress

WordPress uses a modern and intuitive editor for writing content and editing your website. This editor uses blocks for commonly used content and layout elements, which is why it’s called the Block Editor.

However, you may need to use the older Classic Editor in some use cases.

The easiest way to disable the block editor is by using the Classic Editor plugin. However, if you don’t want to use a separate plugin, then just add the following code to your functions file or as a new WPCode snippet:

add_filter('gutenberg_can_edit_post', '__return_false', 5);
add_filter('use_block_editor_for_post', '__return_false', 5);

For more details, see our tutorial on how to disable the Block Editor and use the Classic Editor.

34. Disable Block Widgets in WordPress

WordPress switched from classic widgets to block widgets in WordPress 5.8. The new block widgets are easier to use and give you more design control than classic widgets.

However, some users may still want to use classic widgets. In that case, you can use the following code in your theme’s functions file or as a new WPCode snippet:

add_filter( 'use_widgets_block_editor', '__return_false' );

For more details, see our article on how to disable widget blocks (restore classic widgets).

35. Display the Last Updated Date in WordPress

When visitors view a post or page on your WordPress blog, your WordPress theme will show the date the post was published. This is fine for most blogs and static websites.

However, WordPress is also used by websites where old articles are regularly updated. In these publications, displaying the date and time the post was last modified is essential.

Last updated date

You can show the last updated date using the following code in your theme’s functions file or as a new WPCode snippet:

$u_time          = get_the_time( 'U' );
$u_modified_time = get_the_modified_time( 'U' );
// Only display modified date if 24hrs have passed since the post was published.
if ( $u_modified_time >= $u_time + 86400 ) {

	$updated_date = get_the_modified_time( 'F jS, Y' );
	$updated_time = get_the_modified_time( 'h:i a' );

	$updated = '<p class="last-updated">';

	$updated .= sprintf(
	// Translators: Placeholders get replaced with the date and time when the post was modified.
		esc_html__( 'Last updated on %1$s at %2$s' ),
		$updated_date,
		$updated_time
	);
	$updated .= '</p>';

	echo wp_kses_post( $updated );
}

For alternate methods and more details, see our guide on how to display the last updated date in WordPress.

36. Use Lowercase Filenames for Uploads

If you run a multi-author website, then authors may upload images with filenames in upper and lowercase.

Adding the following code ensures that all filenames are in lowercase:

add_filter( 'sanitize_file_name', 'mb_strtolower' );

Note: The code will not change filenames for existing uploads. For alternate methods, see our tutorial on how to rename images and media files in WordPress.

37. Disable WordPress Admin Bar on Frontend

By default, WordPress displays the admin bar at the top when a logged-in user views your website.

You can disable the admin bar for all users except site administrators. Simply add the following code to your functions file or as a new WPCode snippet:

/* Disable WordPress Admin Bar for all users */
add_filter( 'show_admin_bar', '__return_false' );

For more details, see our guide on how to disable the WordPress admin bar for all users except administrators.

38. Change Howdy Admin Text in Admin Area

WordPress displays a ‘Howdy Admin’ greeting in the WordPress dashboard. ‘Admin’ is replaced by the logged-in user’s name.

Howdy greeting

You can change the default greeting to your own by adding the following code in your functions file or as a new WPCode snippet:

function wpcode_snippet_replace_howdy( $wp_admin_bar ) {

	// Edit the line below to set what you want the admin bar to display intead of "Howdy,".
	$new_howdy = 'Welcome,';

	$my_account = $wp_admin_bar->get_node( 'my-account' );
	$wp_admin_bar->add_node(
		array(
			'id'    => 'my-account',
			'title' => str_replace( 'Howdy,', $new_howdy, $my_account->title ),
		)
	);
}

add_filter( 'admin_bar_menu', 'wpcode_snippet_replace_howdy', 25 );

For more details, see our article on changing the ‘Howdy Admin’ message in WordPress.

39. Disable Code Editing in Block Editor

The block editor allows you to switch to the Code Editor. This comes in handy if you need to add some HTML code manually.

However, you may want to keep this feature limited to site administrators.

You can add the following code to your functions file or as a WPCode snippet to achieve this:

add_filter( 'block_editor_settings_all', function ( $settings ) {
	
	$settings['codeEditingEnabled'] = current_user_can( 'manage_options' );

	return $settings;
} );

40. Disable Plugin / Theme File Editor

WordPress comes with a built-in editor where you can edit plugin files. You can see it by going to the Plugins » Plugin File Editor page.

Plugin file editor in WordPress

Similarly, WordPress also includes a file editor for classic themes at Appearance » Theme File Editor.

Note: If you use a block theme, then the theme file editor is not visible.

Theme file editor

We don’t recommend using these editors for making changes to your theme or plugin. A tiny mistake in code can make your website inaccessible to all users.

To disable the plugin/theme editor, add the following code to your functions file or as a WPCode snippet:

// Disable the Plugin and Theme Editor
if ( ! defined( 'DISALLOW_FILE_EDIT' ) ) {
	define( 'DISALLOW_FILE_EDIT', true );
}

For more details, see our tutorial on how to disable the plugin/theme editor in WordPress.

41. Disable New User Notification Emails

By default, WordPress sends an email notification when a new user joins your WordPress website.

If you run a WordPress membership website or require users to signup, then you will get a notification each time a user joins your website.

To turn off these notifications, you can add the following to your functions file or as a new WPCode snippet:

function wpcode_send_new_user_notifications( $user_id, $notify = 'user' ) {
	if ( empty( $notify ) || 'admin' === $notify ) {
		return;
	} elseif ( 'both' === $notify ) {
		// Send new users the email but not the admin.
		$notify = 'user';
	}
	wp_send_new_user_notifications( $user_id, $notify );
}

add_action(
	'init',
	function () {
		// Disable default email notifications.
		remove_action( 'register_new_user', 'wp_send_new_user_notifications' );
		remove_action( 'edit_user_created_user', 'wp_send_new_user_notifications' );

		// Replace with custom function that only sends to user.
		add_action( 'register_new_user', 'wpcode_send_new_user_notifications' );
		add_action( 'edit_user_created_user', 'wpcode_send_new_user_notifications', 10, 2 );
	}
);

For more details, see our tutorial on how to disable new user email notifications in WordPress.

42. Disable Automatic Update Email Notifications

Occasionally, WordPress may automatically install security and maintenance updates or update a plugin with a critical vulnerability.

It sends an automatic update email notification after each update. If you manage multiple WordPress websites, then you may get several such emails.

You can add this code to your functions file or as a new WPCode snippet to turn off these email notifications:

/ Disable auto-update emails.
add_filter( 'auto_core_update_send_email', '__return_false' );

// Disable auto-update emails for plugins.
add_filter( 'auto_plugin_update_send_email', '__return_false' );

// Disable auto-update emails for themes.
add_filter( 'auto_theme_update_send_email', '__return_false' );

To learn more, see our article on how to disable automatic update emails in WordPress.

43. Add a Link to Easily Duplicate a Post

Ever wished for an easier way to copy all the contents of a post quickly for editing without touching the published post?

The following code snippet will add an option to easily duplicate a post with all its contents:

// Add duplicate button to post/page list of actions.
add_filter( 'post_row_actions', 'wpcode_snippet_duplicate_post_link', 10, 2 );
add_filter( 'page_row_actions', 'wpcode_snippet_duplicate_post_link', 10, 2 );

// Let's make sure the function doesn't already exist.
if ( ! function_exists( 'wpcode_snippet_duplicate_post_link' ) ) {
	/**
	 * @param array   $actions The actions added as links to the admin.
	 * @param WP_Post $post The post object.
	 *
	 * @return array
	 */
	function wpcode_snippet_duplicate_post_link( $actions, $post ) {

		// Don't add action if the current user can't create posts of this post type.
		$post_type_object = get_post_type_object( $post->post_type );

		if ( null === $post_type_object || ! current_user_can( $post_type_object->cap->create_posts ) ) {
			return $actions;
		}


		$url = wp_nonce_url(
			add_query_arg(
				array(
					'action'  => 'wpcode_snippet_duplicate_post',
					'post_id' => $post->ID,
				),
				'admin.php'
			),
			'wpcode_duplicate_post_' . $post->ID,
			'wpcode_duplicate_nonce'
		);

		$actions['wpcode_duplicate'] = '<a href="' . $url . '" title="Duplicate item" rel="permalink">Duplicate</a>';

		return $actions;
	}
}

/**
 * Handle the custom action when clicking the button we added above.
 */
add_action( 'admin_action_wpcode_snippet_duplicate_post', function () {

	if ( empty( $_GET['post_id'] ) ) {
		wp_die( 'No post id set for the duplicate action.' );
	}

	$post_id = absint( $_GET['post_id'] );

	// Check the nonce specific to the post we are duplicating.
	if ( ! isset( $_GET['wpcode_duplicate_nonce'] ) || ! wp_verify_nonce( $_GET['wpcode_duplicate_nonce'], 'wpcode_duplicate_post_' . $post_id ) ) {
		// Display a message if the nonce is invalid, may it expired.
		wp_die( 'The link you followed has expired, please try again.' );
	}

	// Load the post we want to duplicate.
	$post = get_post( $post_id );

	// Create a new post data array from the post loaded.
	if ( $post ) {
		$current_user = wp_get_current_user();
		$new_post     = array(
			'comment_status' => $post->comment_status,
			'menu_order'     => $post->menu_order,
			'ping_status'    => $post->ping_status,
			'post_author'    => $current_user->ID,
			'post_content'   => $post->post_content,
			'post_excerpt'   => $post->post_excerpt,
			'post_name'      => $post->post_name,
			'post_parent'    => $post->post_parent,
			'post_password'  => $post->post_password,
			'post_status'    => 'draft',
			'post_title'     => $post->post_title . ' (copy)',// Add "(copy)" to the title.
			'post_type'      => $post->post_type,
			'to_ping'        => $post->to_ping,
		);
		// Create the new post
		$duplicate_id = wp_insert_post( $new_post );
		// Copy the taxonomy terms.
		$taxonomies = get_object_taxonomies( get_post_type( $post ) );
		if ( $taxonomies ) {
			foreach ( $taxonomies as $taxonomy ) {
				$post_terms = wp_get_object_terms( $post_id, $taxonomy, array( 'fields' => 'slugs' ) );
				wp_set_object_terms( $duplicate_id, $post_terms, $taxonomy );
			}
		}
		// Copy all the custom fields.
		$post_meta = get_post_meta( $post_id );
		if ( $post_meta ) {

			foreach ( $post_meta as $meta_key => $meta_values ) {
				if ( '_wp_old_slug' === $meta_key ) { // skip old slug.
					continue;
				}
				foreach ( $meta_values as $meta_value ) {
					add_post_meta( $duplicate_id, $meta_key, $meta_value );
				}
			}
		}

		// Redirect to edit the new post.
		wp_safe_redirect(
			add_query_arg(
				array(
					'action' => 'edit',
					'post'   => $duplicate_id
				),
				admin_url( 'post.php' )
			)
		);
		exit;
	} else {
		wp_die( 'Error loading post for duplication, please try again.' );
	}
} );

After adding the code, go to the Posts » All Posts screen and take your mouse over to a post title.

You’ll notice a new ‘Duplicate’ link under the options.

Duplicate post link

Clicking on the link will create a copy of the post with all its contents. You can then work on that draft.

Once finished, you can copy and paste your changes to the original published post and delete the copy.

For a plugin method, see our article on duplicating a WordPress post or page.

44. Remove Welcome Panel From the WordPress Admin Dashboard

The Welcome Panel appears in the WordPress admin dashboard. It can be easily dismissed or hidden by clicking on the ‘Screen Options’ button.

Welcome panel

However, if you are working to make a cleaner dashboard experience for users, you may want to hide it permanently.

Add the following code to disable it for all users on your site:

add_action(
	'admin_init',
	function () {
		remove_action( 'welcome_panel', 'wp_welcome_panel' );
	}
);

45. Add a Featured Image Column for Posts in WordPress Admin

By default, WordPress only shows featured images when you are viewing your site or when you edit a post or page.

The following code will add a new column to the Posts » All Posts screen for featured images:

add_filter( 'manage_posts_columns', function ( $columns ) {
	// You can change this to any other position by changing 'title' to the name of the column you want to put it after.
	$move_after     = 'title';
	$move_after_key = array_search( $move_after, array_keys( $columns ), true );

	$first_columns = array_slice( $columns, 0, $move_after_key + 1 );
	$last_columns  = array_slice( $columns, $move_after_key + 1 );

	return array_merge(
		$first_columns,
		array(
			'featured_image' => __( 'Featured Image' ),
		),
		$last_columns
	);
} );

add_action( 'manage_posts_custom_column', function ( $column ) {
	if ( 'featured_image' === $column ) {
		the_post_thumbnail( array( 300, 80 ) );
	}
} );

Here is how it would look after adding the code.

Featured image column

46. Block WordPress Admin Area for Everyone Except Administrators

Some WordPress websites may need users to register an account. For instance, a WordPress membership site or an eCommerce store.

Most such plugins will prevent those users from accessing the admin area. However, if you are not using such a plugin, then you can add the following code to block all users except administrators from accessing the admin area:

add_action( 'admin_init', function() {
	if ( ! current_user_can( 'administrator' ) ) {
       wp_redirect( home_url() );
       exit;
	}
} );

Users with other user roles can still log in to their accounts, but after logging in, they will be redirected to the homepage.

We hope this article helped you learn some new useful tricks for the functions.php file in WordPress. You may also want to see our guide on displaying code in WordPress to share your snippets easily and our expert picks for the best code editors for Mac and Windows.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

120 CommentsLeave a Reply

  1. Robert Phillips-Legge

    Some useful tips, but there is one thing to be taken into consideration. If you create a Child Theme you can update the functions.php with impunity because any Theme update won’t affect it. In addition in one website WP-Code was itself the culprit. in preventing access to the site. On trying to mark a snippet as unused it crashed and I had to delete it at the file system level. Fortunately I had all the code snippets in a separate file and was able to update the functions.php in the child theme and copy CSS into in the the theme and enqueue the JavaScript files. WP-Code is good but not perfect. Make sure you have a Plan B.

    Also Google say, on their Page Lightspeed pages that they don’t penalise you in SEO for having a lot of plugins. All they’re interested in is the quality of the code. If it’s bad you’ll get marked down. If it’s good, you get to keep your Gold Star and a Tick.

  2. Dennis Muthomi

    This is a goldmine
    I loved the featured image column in the admin area (#45) I manage a content heavy site and this has made a huge difference in my workflow.
    What I love about your articles is that you consistently provide code that addresses the exact issues I’m facing, and the best part is, the code always works perfectly.
    Thanks for this article WPBeginner!

  3. Mrteesurez

    It is a best practice and always advisable to add custom code with WPcode, it is a blessing to have such plugin.
    How will you maintain codes snippets added directly to functions file, it will be a bad experience for your users when you messed up with some vital functions file codes and suddenly break your site.
    Thanks for those snippets and tips to secure and improve our sites.

    • Jiří Vaněk

      Exactly as you wrote, Mrteesurez. Sometimes it is better to leave pieces of code to the software, because a person can very easily harm themselves instead of helping. The second and equally important thing, which I would also mention, is that thanks to WP Code, you won’t lose your codes when the template gets updated or when you change it for another. This is also a very nice and important benefit that is worth mentioning.

      • Mrteesurez

        Thank you for your valuable contribution and for pointing out this crucial insight. You’re absolutely right, leaving code to the software can prevent potential issues that might arise from manual errors. Also, WPcode preserves the customizations during updates is a game-changer as I will not be fearing of losing the custom I have code added. Thanks again for highlighting this.

  4. Moinuddin Waheed

    So much to accomplish with the help of functions.php
    I think this is the core of the WordPress and if we do too much to it, we may lose many core functionalities.
    having said this, using wpcode is a wise idea to insert anything for functionality without compromising the WordPress core.
    I have a question though, if wpcode doesn’t insert it’s code in the main functions.php then how it works?
    and if inserts it into the same, how updating wordpress doesn’t erase it?

    • WPBeginner Support

      The code is stored in your database and the plugin hooks in the code in different ways depending on how you set it in the plugin.

      Admin

      • Mrteesurez

        Thanks for this answer. I have been curious to know how this WPcode works that new update didn’t erase the code snippets and during switching of themes. You answer has cleared it to me, I appreciate this support.

  5. Jiří Vaněk

    I’ve noticed that on some websites, the top part of the browser changes color, specifically on mobile Chrome. Do you have any tested snippet that accomplishes this?

  6. Ralph

    A lot of great ideas explained in novice friendly way. Thanks! I will try adding featured images to RSS feeds. It never worked before for some reason and now it will :)

    • WPBeginner Support

      Glad to hear you found our tricks helpful :)

      Admin

  7. Ben

    This is a pretty dangerous idea. Query strings exist for the purposes of cache busting, aka, making sure the end user has the latest version your js and css files.

    Removing those is going to cause all sorts of issues for returning users down the line as their browser will assume nothing has changed and use their cached version rather than downloading the new one.

    If for some reason you need to target a specific file and remove the query string (which I’ve had to do) you can use this code snippet:

    // remove version from scripts and styles
    function remove_version_scripts_styles($src) {
    if (strpos($src, ‘yourfile.js’)) {
    $src = remove_query_arg(‘ver’, $src);
    }
    return $src;
    }
    add_filter(‘script_loader_src’, ‘remove_version_scripts_styles’, 9999);

  8. Gean Paulo Francois

    Very useful article. I just saved this page offline so I can insert some of these with my websites. Anyway, should I add the codes to functions,php and not anywhere else?

    • WPBeginner Support

      Correct, these codes are for your functions.php file.

      Admin

  9. Hussain Badusha

    Nice compendium of some useful tricks and functions for wordpress. I added quite a new things to my wordpress knowledge after going through here.

    I look forward even more from you if you wish to

    • WPBeginner Support

      Glad you found our guide helpful :)

      Admin

  10. Satinder Satsangi

    Oh WoW,

    This is lifesaver most of the times, would like to know more about useful functions.

    • WPBeginner Support

      Glad you found our guide helpful :)

      Admin

  11. vivek

    Nice article,

    Just have a doubt if I am supposed to add these codes in snippets plugin or somwhere in file? if its snippet plugin, it’s not working. Kindly put some light.
    Thanks

    • WPBeginner Support

      You would add these codes as a custom plugin or more commonly in your functions.php file

      Admin

  12. Beulah Wellington

    Thank you for this tutorial. I learned a lot. I will be reading it again.

    • WPBeginner Support

      You’re welcome, glad our guide can continue to help you :)

      Admin

  13. Ali Jahani

    Hi
    Thanks a lot of….

    wpbeginner Is god team

    • WPBeginner Support

      You’re welcome, glad you like our content :)

      Admin

  14. VISHAL CHOWDHRY

    Superb Article.
    Waiting for more of this :)

    • WPBeginner Support

      Thank you, glad you liked our content :)

      Admin

  15. Miley Cyrus

    Great Article it its really informative and innovative keep us posted with new updates. its was really valuable. thanks a lot.

    • WPBeginner Support

      Glad our article could be helpful :)

      Admin

  16. John Dee

    Almost NONE of these code snippets belong in your theme’s functions.php file. Only a few of them are related to the actual theme. Themes are for APPEARANCE. Create a PLUGIN for functionality. In any case, it would go in child theme’s functions.php file.

    • WPBeginner Support

      Thank you for pointing this out, while we do mention site-specific plugins at the beginning of this article, we will be sure to look into making that statement clearer.

      Admin

  17. Suman Samanta

    Nice information for a new bloggers. It is really helpful.

  18. Richard Yzenbrandt

    Thank you so much for making this resource available. WP for Beginners is the best goto site on the web!

  19. alok patel

    hey i am unable to add my post on specific page. when i write any blog post it shows in home page but i wanna also see in specific pages where i want to add. how i can out of from this problem. plz help me as soon as possible. if any video link thn plz share with reply. i m getting too much confused.

  20. DONALD

    I am creating a form to collect data from my users.
    I have created the database from myphpAdmin
    I have created the form.
    I now created a new php.file in my child theme
    I referenced it in the form too using action = “name.php”
    Now i expect it to gather, peoples registration details.
    But clicking on submit on the form, says, page cannot be found.
    I dont know what i am not getting right.
    Please help me

  21. marvin N N

    is there a plugin one can use to customise a theme’s default menu setting to suit your taste???

  22. Sazzad Hossain

    Thanks for this codes.

  23. Shafiq Khan

    Very useful post thanks.

    A question – Because you’re updating the functions.php of a theme.
    If you update the theme then you lose your tweaks.

    Is there a way around this? Is it just a cause of using a Child theme?

    Thanks

    • Lisa

      Hi Shafiq,

      Any changes you make to a parent theme will be overwritten when you update it. It is good practice to work with a child theme when making changes to a theme you didn’t build that is going to be updated so that you can keep the changes you made.

    • Jan

      I use the plugin ‘My Custom Functions’ – it is simply adding all functions to the functions.php automatically – so no re-writing after every update needed :)

    • Jane Lawson

      This is late, but you can also create a plugin for your site (e.g. “[Site name]’s custom plugin”). It does require a bit of expertise, however, since some functions clash with other plugins/the site theme.

  24. Neil

    Excellent post – thank you for the tips & tricks. They are all very helpful :)

  25. Karakaplan

    How to use these above with child theme functions file?

    • Minhaz

      Nothing difference with parent or child theme’s functions.php

  26. Joe

    I’ve not done much with the functions file so it was good to see this article.

    Thanks.

  27. Jorge Rosa

    Great snippets. Very handy and useful. Thank You!

  28. sriganesh

    this is best site for wordpress

  29. Bilal

    will you tell me a most easy book for wordpress.
    i am very new in this field .
    thanks in advance

  30. Al1

    Another one :

    // Remove query string from static files :
    function remove_cssjs_ver( $src ) {
    if( strpos( $src, ‘?ver=’ ) )
    $src = remove_query_arg( ‘ver’, $src );
    return $src;
    }
    add_filter( ‘style_loader_src’, ‘remove_cssjs_ver’, 10, 2 );
    add_filter( ‘script_loader_src’, ‘remove_cssjs_ver’, 10, 2 );

  31. siva

    Great post, Could provide all wordpress function with example

  32. shojib

    This is the best blog for Wordpress users.

  33. Parveen

    Great post!!!
    I am a newbie and looking for such tricks.
    Thanks.

  34. Deepak Kanyan

    Really a nice blog. i had learn lot of things from here thanks admin.

  35. Andrew

    I tried #16 to add the post featured thumbnail to m RSS feed but when I tested it in mailchimp (paused my campaign and previewed) it appears that it has changed from “summary” to “full text”? Is this expected behaviour? I want to leave the emails (rss driven) as summary, and simply add the thumbnail featured image at the top.

    Thanks for any help, I can’t find this on google anywhere.

  36. Em Cloney

    re: removing rss feed for static pages — is it correct that the txt one would replace in that code is ‘url’ (with a page link, including ) and ‘homepage’ (if you’d like it to say something else, like ‘some other site’)?

  37. Mohan Manohar

    This is huge list and great help. would like to know the first part of twitter counter code is to be pasted in function.php or directly into texty widget of theme.

  38. grafx

    There is an easier way to remove WordPress Version Number…

    remove_action(‘wp_head’, ‘wp_generator’);

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.