Joel Always one syllable, sometimes "@jayroh"

Meta descriptions and keywords for each page and post in WordPress

03 Apr 2009

After searching for a plugin that might accommodate this in WordPress and coming up empty, I went digging for a possible easy way to do this with the means available.   Logic dictates that with custom fields this should be rather easy to accomplish.

The only snag might have been that in retreiving a custom field for a page or a post you need the page or post’s ID.   Usually this id is readily available within “the loop”, but what about when we’re up in the tags?    A little searching in the codex reveals that we can grab your pages’ ID with $wp_query->post->ID.  Fantastic – because, with that we’re pretty much done! Adding the following in your theme’s header.php file between … :

” />
” />

.. and “meta_keywords” and “meta_description” as custom fields with your desired content for each will get you to where you want to be.

I'm working on something called shubox.io!

Want to know more about it? (Answer: "Yes. I do") Check it out or sign up for my newsletter to receive news, announcements and other good bits!