How to implement custom Meta Descriptions, Meta Keywords, and Robot Meta Tags into your theme without using plugins and branding it as your own. Right off the bat, this post is not for regular WordPress users. This is for experienced theme developers and those who specifically can read and write PHP.
WordPress SEO seems to be the easiest thing to do with all the free plugins out there, and they make it look like that a monkey can get a good result as long as they use a high rated plugin. The problem that I have with almost all SEO plugins is the amount of garbage that comes with them or in some cases, the intentional link placing of the authors in the code to get your precious page-rank directed at their own sites. Take Yoast SEO Plugin for example. The author is so pompous and arrogant that in a discussion on wordpress.org, when many people asked him to remove his link from the source or give option for the user to do it, he uttered that “I’ll never offer a way to take them [links to his website] out via the back-end.”
I don’t know about you but if I spend my time optimizing a site, I sure as hell don’t like to give my hard earned ranking to someone else. And I take it even more seriously when it comes to my clients. They are paying good money for the best possible result, and by cutting corners and using garbage plugins, I would be cheating them, and that’s not OK in my book.
What I have put together here is a clean and easy way to implement Meta Descriptions, Meta Keywords, and Meta Robot Tags, into your posts, pages, archives, categories,… and also the means to set global keywords for all pages. I’ve written this code based on the excellent “Custom Metaboxes” library and not only you get perfect SEO functionality; you also get all the goodies of the Custom Metaboxes as well. A big thank you and truckload of credit goes to CMB developers; Bill Erickson, Jared Atchison, Andrew Norcross, and many others who’ve contributed to this great project.
Make sure to remove all other meta description and keyword codes from the head if you have any. I’ve commented on every block of code so you can follow easily even if you’re not very PHP savvy.
Once you’ve installed the script, look under your “settings/general” in the WordPress admin and you’ll see another field for Global keywords. Fill in your desired keywords and proceed to individual posts and pages.
The result will look like the following on every page and post. (If you have custom post types, no problem, just add your post type to the function code and you’re done)
So instead of confusing your clients and yourself with million useless options, do it right the first time and have your theme SEO ready. Even if the client doesn’t enter anything in the SEO box, Meta Description and Keywords will automatically be generated based on the site description, and global keywords.
Hope you like this little “un-plugin” and if you have any questions or comments, post them below.