Latest Tech and Tips

32 Extremely Useful Tricks for the WordPress Functions File

7

All WordPress themes include a strong capabilities.php file. This file acts as a plugin and permits you to do a number of cool issues in your WordPress website. In this text, we’ll present you a few of the most helpful methods for your WordPress capabilities file.

Most useful tricks for WordPress functions file

What is Functions File in WordPress?

Functions file generally often known as capabilities.php file is a WordPress theme file. It comes with all free and premium WordPress themes.

The goal of this file is to permit theme builders to outline theme options and capabilities. This file acts identical to a WordPress plugin and can be utilized so as to add your personal {custom} code snippets in WordPress.

You would discover many of those code snippets on web sites like WPBeginner with directions telling you so as to add this code in your theme’s capabilities.php file or a site-specific WordPress plugin.

Now you could be pondering what’s the distinction between a site-specific WordPress plugin and capabilities.php file? Which one is best?

While capabilities.php file is extra handy, a site-specific plugin is a lot better. Simply as a result of it’s impartial of your WordPress theme and would work no matter which theme you’re utilizing.

On the different hand, a theme’s capabilities file will solely work for that theme and in case you change the theme, then you’ll have to copy / paste your {custom} codes into the new theme.

Having mentioned that, listed below are some extraordinarily helpful methods for the WordPress capabilities file.

1. Remove WordPress Version Number

You ought to all the time use the newest model of WordPress. However, you should still need to take away the WordPress model quantity out of your website. Simply add this code snippet to your capabilities file.

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

For detailed directions, see our information on the proper approach to take away WordPress model quantity.

Want to white label your WordPress admin space? Adding a {custom} dashboard emblem is the first step in the course of.

First you’ll must add your {custom} emblem to your theme’s photos folder as custom-logo.png. Make positive your {custom} emblem is 16×16 pixels in dimension.

After which you could add this code to your theme’s capabilities file.

operate wpb_custom_logo() {
echo '
<model kind="text/css">
#wpadminbar #wp-admin-bar-wp-logo > .ab-item .ab-icon:earlier than {
background-image: url(' . get_bloginfo('stylesheet_directory') . '/photos/custom-logo.png) !vital;
background-position: 0 0;
colour:rgba(0, 0, 0, 0);
}
#wpadminbar #wp-admin-bar-wp-logo.hover > .ab-item .ab-icon {
background-position: 0 0;
}
</model>
';
}
//hook into the administrative header output
add_action('wp_before_admin_bar_render', 'wpb_custom_logo');

For alternate strategies and extra particulars see our information on learn how to add a {custom} dashboard emblem in WordPress.

3. Change the Footer in WordPress Admin Panel

The footer in WordPress admin space exhibits the message ‘Thank you for creating with WordPress’. You can change it to something you need by including this code.

operate remove_footer_admin ()  WordPress Tutorials: <a href="https://www.wpbeginner.com" goal="_blank">WPBeginner</a></p>';



add_filter('admin_footer_text', 'remove_footer_admin');

Feel free to alter the textual content and hyperlinks that you simply need to add. Here is the way it seems to be on our take a look at website.

Custom footer in WordPress admin area

4. Add Custom Dashboard Widgets in WordPress

You most likely have seen widgets that quite a few plugins and themes add in the WordPress dashboard. As a theme developer, you may add one your self by pasting the following code:

add_action('wp_dashboard_setup', 'my_custom_dashboard_widgets');

operate my_custom_dashboard_widgets() {
international $wp_meta_boxes;

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

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

This is how it might appear to be:

Custom dashboard widget in WordPress

For particulars, see our tutorial on learn how to add {custom} dashboard widgets in WordPress.

5. Change the Default Gravatar in WordPress

Have you seen the default thriller man avatar on blogs? You can simply change it with your personal branded {custom} avatars. Simply add the picture you need to use as default avatar after which add this code to your capabilities file.

add_filter( 'avatar_defaults', 'wpb_new_gravatar' );
operate wpb_new_gravatar ($avatar_defaults) {
$myavatar = 'http://example.com/wp-content/uploads/2017/01/wpb-default-gravatar.png';
$avatar_defaults[$myavatar] = "Default Gravatar";
return $avatar_defaults;
}

Now you may head over to Settings » Discussion web page and choose your default avatar.
Custom default gravatar

For detailed directions, see our information on learn how to change the default gravatar in WordPress.

6. Dynamic Copyright Date in WordPress Footer

You can merely add copyright date by enhancing the footer template in your theme. However, it won’t present when your website began and it’ll not mechanically change subsequent yr.

You can use this code so as to add a dynamic copyright date in WordPress footer.

operate wpb_copyright() {
international $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 including this operate, you’ll must open your footer.php file and add the following code wherever you prefer to show the dynamic copyright date:

<?php echo wpb_copyright(); ?>

This operate seems to be for the date of your first put up, and the date of your final put up. It then echos the years wherever you name the operate.

For extra particulars, see our information on learn how to add dynamic copyright date in WordPress.

7. Randomly Change Background Color in WordPress

Do you need to randomly change background colour in your WordPress upon every go to and web page reload? Here is learn how to simply do that.

First it’s essential add this code to your theme’s capabilities file.

operate wpb_bg() { 
$rand = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f');
$colour ='#'.$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 $colour;
}

Next, you’ll must edit the header.php file in your theme. Locate the <physique> tag and add change it with this line:

<physique <?php body_class(); ?> model="background-color:<?php wpb_bg();?>">>

You can now save your adjustments and go to your web site to see this in motion.

Random background change in WordPress

For extra particulars and alternate strategies, see our tutorial on learn how to randomly change background colour in WordPress.

8. Update WordPress URLs

If your WordPress login web page retains refreshing or you’re unable to entry admin space, then it’s essential replace WordPress URLs.

One method to do that is by utilizing wp-config.php file. However, in case you do that you simply will be unable to set the right tackle on the settings web page. The WordPress URL and Site URL fields shall be locked and uneditable.

If you need to repair this, then you must add this code to your capabilities file.

update_option( 'siteurl', 'http://example.com' );
update_option( 'residence', 'http://example.com' );

Don’t overlook to switch instance.com with your personal area identify.

Once you’re logged in, you may go to Settings and set the URLs there. After that you must take away the code you added to the capabilities file, in any other case it’ll preserve updating these URLs any time your website is accessed.

9. Add Additional Image Sizes in WordPress

WordPress mechanically creates a number of picture sizes while you add a picture. You can even create further picture sizes to make use of in your theme. Add this code your theme’s capabilities file.

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 picture sizes with totally different sizes. Feel free to tweak the code to satisfy your personal necessities.

You can show a picture dimension in anyplace in your theme utilizing this code.

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

For detailed directions, see our information on learn how to create further picture sizes in WordPress.

10. Add New Navigation Menus to Your Theme

WordPress permits theme builders to outline navigation menus after which show them. Add this code in your theme’s capabilities file to outline a brand new menu location in your theme.

operate 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 and you will note ‘My Custom Menu’ as theme location choice.

New navigation menu

Now it’s essential add this code to your theme the place you need to show navigation menu.

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

For detailed directions, see our information on learn how to add {custom} navigation menus in WordPress themes.

11. Add Author Profile Fields

Do you need to add additional fields to your writer profiles in WordPress? You can simply do this by including this code to your capabilities file:

operate 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 consumer profiles in WordPress.

Extra user profile fields in WordPress

You can now show these fields in your writer template like this:

<?php echo $curauth->twitter; ?>

You might also need to see our information on learn how to add further consumer profile fields in WordPress registration.

12. Adding Widget Ready Areas or Sidebar in WordPress Themes

This is one in every of the most used ones and plenty of builders already find out about this. But it deserves to be on this listing for those that don’t know. Paste the following code in your capabilities.php file:

// Register Sidebars
operate custom_sidebars() {

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

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

You can now go to Appearance » Widgets web page and you will note your new {custom} widget space.

Newly registered widget area in WordPress

To show this sidebar or widget prepared space in your theme add this code:

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

For extra particulars see our information on learn how to add dynamic widget prepared areas and sidebars in WordPress.

13. Manipulate RSS Feed Footer

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


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

For extra info, see our information on learn how to add content material and utterly manipulate your RSS feeds.

14. Add Featured Images to RSS Feeds

The put up thumbnail or featured photos are often solely displayed inside your website design. You can simply prolong that performance to your RSS feed with a easy operate in your RSS feed.

operate rss_post_thumbnail($content material) {
international $put up;
if(has_post_thumbnail($post->ID)) {
$content material = '<p>' . get_the_post_thumbnail($post->ID) .
'</p>' . get_the_content();
}
return $content material;
}
add_filter('the_excerpt_rss', 'rss_post_thumbnail');
add_filter('the_content_feed', 'rss_post_thumbnail');

For extra particulars see our information on learn how to add put up thumbnails to your WordPress RSS feed.

15. Hide Login Errors in WordPress

Login errors in WordPress can be utilized by hackers to guess whether or not they entered incorrect username or password. By hiding login errors in WordPress you can also make your login space a bit safer.

operate no_wordpress_errors(){
  return 'Something is incorrect!';
}
add_filter( 'login_errors', 'no_wordpress_errors' );

Now customers see a generic message once they enter incorrect username or password.

No login hints in WordPress

For extra info, see our tutorial on learn how to disable login hints in WordPress login error messages.

16. Disable Login by Email in WordPress

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

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

For extra info see our information on learn how to disable login by electronic mail characteristic in WordPress.

17. Disable Search Feature in WordPress

If you need to disable search characteristic in your WordPress website, then merely add this code to your capabilities file.

operate fb_filter_query( $question, $error = true ) {

if ( is_search() ) {
$query->is_search = false;
$query->query_vars[s] = false;
$query->question[s] = false;

// to error
if ( $error == true )
$query->is_404 = true;
}
}

add_action( 'parse_query', 'fb_filter_query' );
add_filter( 'get_search_form', create_function( '$a', "return null;" ) );

For extra info, see our tutorial on learn how to disable search characteristic in WordPress.

18. Delay Posts in RSS Feed

Sometimes you could find yourself with a grammar or spelling mistake in your article. The mistake goes stay and is distributed to your RSS feed subscribers. If you will have electronic mail subscriptions in your WordPress weblog, then these subscribers will get it as properly.

Simply add this code in your theme’s capabilities file.

operate publish_later_on_feed($the place) {

	international $wpdb;

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

		// worth for wait; + machine
		$wait = '10'; // integer

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

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

add_filter('posts_where', 'publish_later_on_feed');

In this code we’ve got used 10 minutes as $wait or delay time. Feel free to alter that into any variety of minutes you need.

For plugin methodology and extra info, see our detailed information on learn how to delay posts from showing in WordPress RSS feed.

19. Change Read More Text for Excerpts in WordPress

Do you need to change the textual content that seems after the excerpt? Simply add this code to your theme’s capabilities file.

operate modify_read_more_link() {
    return '<a category="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 web sites want RSS feeds. If you need to disable RSS feeds in your WordPress website, then add this code to your theme’s capabilities file.

operate fb_disable_feed() {
wp_die( __('No feed out there,please go to our <a href="'. get_bloginfo('url') .'">homepage</a>!') );
}

add_action('do_feed', 'fb_disable_feed', 1);
add_action('do_feed_rdf', 'fb_disable_feed', 1);
add_action('do_feed_rss', 'fb_disable_feed', 1);
add_action('do_feed_rss2', 'fb_disable_feed', 1);
add_action('do_feed_atom', 'fb_disable_feed', 1);

For a plugin methodology and extra info, see our information on learn how to disable RSS feeds in WordPress.

21. Change Excerpt Length in WordPress

WordPress limits excerpt lengths to 55 phrases. If it’s essential change that, then you may add this code to your capabilities file.

operate new_excerpt_length($size) {
return 100;
}
add_filter('excerpt_length', 'new_excerpt_length');

Change 100 to the variety of phrases you need to present in the excerpts.

For alternate methodology, it’s your decision to check out our information on learn how to customise WordPress excerpts (no coding required).

22. Add an Admin User in WordPress

If you will have forgotten your WordPress password and electronic mail, then you may add an admin consumer by including this code to your theme’s capabilities file utilizing an FTP consumer.

operate wpb_admin_account(){
$consumer = 'Username';
$cross = 'Password';
$electronic mail = 'electronic mail@area.com';
if ( !username_exists( $consumer )  && !email_exists( $electronic mail ) ) {
$user_id = wp_create_user( $consumer, $cross, $electronic mail );
$consumer = new WP_User( $user_id );
$user->set_role( 'administrator' );
} }
add_action('init','wpb_admin_account');

Don’t overlook to fill in the username, password, and electronic mail fields. Once you login to your WordPress website, don’t overlook to delete the code out of your capabilities file.

For extra on this matter, check out our tutorial on learn how to add an admin consumer in WordPress utilizing FTP.

23. Remove Welcome Panel from WordPress Dashboard

Welcome panel is a meta field added to the dashboard display of WordPress admin space. It gives helpful shortcuts for inexperienced persons to do issues on their new WordPress website.

Welcome panel in WordPress admin dashboard

You can simply disguise by including this code in your capabilities file.

remove_action('welcome_panel', 'wp_welcome_panel');

For different strategies and extra particulars take a look at our information on learn how to take away welcome panel in WordPress dashboard.

24. Show Total Number of Registered Users in WordPress

Do you need to present whole variety of registered customers in your WordPress website? Simply add this code to your theme’s capabilities file.

// Function to return consumer depend
operate wpb_user_count() { 
$usercount = count_users();
$end result = $usercount['total_users']; 
return $end result; 
} 
// Creating a shortcode to show consumer depend
add_shortcode('user_count', 'wpb_user_count');

This code creates a shortcode that permits you to show whole variety of registered customers in your website. Now you simply want so as to add this shortcode to [user_count] your put up or web page the place you need to present the whole variety of customers.

For extra info and a plugin methodology, see our tutorial on learn how to show whole variety of registered customers in WordPress.

25. Exclude Specific Categories from RSS Feed

Do you need to exclude particular classes out of your WordPress RSS feed? Add this code to your theme’s capabilities file.

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

26. Enable Shortcode Execution in Text Widgets

By default, WordPress doesn’t execute shortcodes inside textual content widgets. To repair this it’s essential merely add this code to your theme’s capabilities file.

// Enable shortcodes in textual content widgets
add_filter('widget_text','do_shortcode');

For an alternate methodology and extra info, check out our information on learn how to use shortcodes in WordPress sidebar widgets.

27. Add Odd and Even CSS Classes to WordPress Posts

You could have seen WordPress themes utilizing an outdated and even class for WordPress feedback. It helps customers visualize the place one remark ends and the subsequent one begins.

You can use the similar approach for your WordPress posts. It seems to be aesthetically pleasing and helps customers shortly scan pages with a number of content material. Simply add this code to your theme’s capabilities file.

operate oddeven_post_class ( $lessons ) {
   international $current_class;
   $lessons[] = $current_class;
   $current_class = ($current_class == 'odd') ? 'even' : 'odd';
   return $lessons;
}
add_filter ( 'post_class' , 'oddeven_post_class' );
international $current_class;
$current_class = 'odd';

This code merely provides an odd and even class to WordPress posts. You can now add {custom} CSS to model them in another way. Here is a pattern code that will help you get began.

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

The finish end result will look one thing like this:

Alternate colors used for WordPress posts using odd and even CSS classes

Need extra detailed directions? Take a have a look at our tutorial on learn how to add odd/even class to your put up in WordPress themes.

28. Add Additional File Types to be Uploaded in WordPress

By default, WordPress permits you to add a restricted variety of mostly used file varieties. However, you may prolong it to permit different file varieties. Add this code to your theme’s capabilities file:

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

This code permits you to add SVG and PSD information to WordPress. You might want to Google to seek out out the mime varieties for the file varieties you need to permit after which use it in the code.

For extra on this matter, take a look at our tutorial on learn how to add further file varieties to be uploaded in WordPress.

By default, while you add a picture in WordPress it’s mechanically linked to the picture file or the attachment web page. If customers click on on the picture they’re then taken to a brand new web page away out of your put up.

Here is how one can simply cease WordPress from mechanically linking picture uploads. All you must do is so as to add this code snippet to your capabilities file:

operate wpb_imagelink_setup() {
	$image_set = get_option( 'image_default_link_type' );
	
	if ($image_set !== 'none') {
		update_option('image_default_link_type', 'none');
	}
}
add_action('admin_init', 'wpb_imagelink_setup', 10);

Now while you add a brand new picture in WordPress, it won’t be mechanically linked. You can nonetheless hyperlink it to the file or attachment web page if you would like.

Disable default image links in WordPress

You could need to take a look at our tutorial on learn how to take away default picture hyperlinks in WordPress for an alternate plugin methodology and extra info.

30. Add an Author Info Box in WordPress Posts

If you run a multi-author website and need to showcase writer bios at the finish of your put up, then you may do this methodology. Start by including this code to your capabilities file:

operate wpb_author_info_box( $content material ) {

international $put up;

// Detect if it's a single put up with a put up writer
if ( is_single() && isset( $post->post_author ) ) {

// Get writer's show identify 
$display_name = get_the_author_meta( 'display_name', $post->post_author );

// If show identify will not be out there then use nickname as show identify
if ( empty( $display_name ) )
$display_name = get_the_author_meta( 'nickname', $post->post_author );

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

// Get writer's web site URL 
$user_website = get_the_author_meta('url', $post->post_author);

// Get hyperlink to the writer archive web page
$user_posts = get_author_posts_url( get_the_author_meta( 'ID' , $post->post_author));
 
if ( ! empty( $display_name ) )

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

if ( ! empty( $user_description ) )
// Author avatar and bio

$author_details .= '<p class="author_details">' . get_avatar( get_the_author_meta('user_email') , 90 ) . nl2br( $user_description ). '</p>';

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

// Check if writer has an internet site of their profile
if ( ! empty( $user_website ) )  <a href="' . $user_website .'" goal="_blank" rel="nofollow">Website</a></p>';

 else { 
// if there isn't any writer web site then simply shut the paragraph
$author_details .= '</p>';
}

// Pass all this information to put up content material  
$content material = $content material . '<footer class="author_bio_section" >' . $author_details . '</footer>';
}
return $content material;
}

// Add our operate to the put up content material filter 
add_action( 'the_content', 'wpb_author_info_box' );

// Allow HTML in writer bio part 
remove_filter('pre_user_description', 'wp_filter_kses');

Next you will have so as to add some {custom} CSS to make it look higher. You can use this pattern CSS as an place to begin.

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

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

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

This is how your writer field would appear to be:

Author box

For plugin methodology and extra detailed directions, take a look at our article on learn how to add an writer information field in WordPress posts.

31. Disable XML-RPC in WordPress

XML-RPC is a technique that permits third get together apps to speak together with your WordPress website remotely. This may trigger safety points and could be exploited by hackers.

Simply add this code to your capabilities file to show off XML-RPC in WordPress:

add_filter('xmlrpc_enabled', '__return_false');

You could need to learn our article on learn how to disable XML-RPC in WordPress for extra info.

32. Automatically Link Featured Images to Posts

If your WordPress theme doesn’t mechanically hyperlink featured photos to full articles, then you may do this methodology. Simply add this code to your theme’s capabilities file.

operate 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 could need to learn our article on learn how to mechanically hyperlink featured photos to posts in WordPress.

That’s all for now.

We hope this text helped you study some new helpful methods for capabilities.php file in WordPress. You might also need to see our final information to spice up WordPress velocity and efficiency.

If you appreciated this text, then please subscribe to our YouTube Channel for WordPress video tutorials. You can even discover us on Twitter and Facebook.