How to Add Custom Meta Description for Home Page in WordPress

/* Adding Custom Meta Description to the Home Page */
add_action('wp_head', 'wpflt_header_function_condition_description');
function wpflt_header_function_condition_description(){
if(is_front_page()) { ?>
<meta name="description" content="This is the Custom Meta Description for Our Website. This description is 900px long which is perfect to display in Search Results"/>
<?php }
};

If you are not using any SEO plugin, you probably need to manually add a custom meta description for your home page. In general, Google will automatically fetch and create its own meta descriptions for other pages and posts.

When it comes to home page, most pages are either ‘custom created’ or ‘archives’. Google fetches the first words it can find and sets it as the meta description. This doesn’t look good when our main homepage is displayed in search results with some random meta description.

Add the above code to your child theme’s ‘functions.php’ file. Add the meta description you want to show for the homepage. Run before and after tests through meta description testing websites. You may notice we have used the ‘is_front_page()‘ attribute which applies for any page which is set as the front page of the website. If you use ‘is_home()‘, it only applies if the front page is an archive page of all posts.