Home » Php » How to display a meta description on a site's homepage

How to display a meta description on a site's homepage

Posted by: admin September 16, 2018 Leave a comment

Questions:

What I’m trying to do:

Add a meta description to my WordPress website homepage.

Under what conditions:

The homepage normally has my latest posts on it, so that search engines pick up the description on the latest blog post as the meta description for the site itself.

My goal is to only specify a meta description for the homepage, and not for any of the other posts/pages.

This description needs to be text that isn’t available in other areas of the site (i.e. not in the bloginfo() function).

I’m trying to do this using my own plugin, so that I don’t have to modify the header.php file directly (since this would mean that I have to modify it each time WP is updated), and so that I don’t have to use an external plugin.

There are a few existing questions on the topic (e.g. this one), but none of them explains how to do this exactly.

Answers: