0815

Du musst dich anmelden um Beiträge und Themen zu erstellen. Einloggen · Registrieren

Meta Descriptions without a Plugin

We don’t need no stinkin’ plugin for custom meta descriptions. All you need is a custom field named “metadescription” with the desired meta description for each post. Once you have that going, include the following function to your theme’s header.php file (within the <head> section:

<meta name="description" content="
<?php if ((is_home()) || (is_front_page())) {
	echo ('Your main description goes here');
} elseif(is_category()) {
	echo category_description();
} elseif(is_tag()) {
	echo 'Tag archive page for this blog - ' . single_tag_title();
} elseif(is_month()) {
	echo 'Archive page for this blog - ' . the_time('F, Y');
} else {
	echo get_post_meta($post->ID, 'metadescription', true);
} ?>" />

This function enables you to customize the descriptions for various types of pages, such as the home page, category pages, tag archives, and so on. For single post-view pages, this function will display the value of the metadescription custom field.

Source: Malcolm Coles (404 link removed)




0