Mai devreme a trecut pe la mine Greyheart, si mi-a spus ca lucreaza cu un prieten la o solutie de a folosi TAG-urile unui post WordPress ca META Keywords si excerpt ca META Description.
M-am hotarat sa pun Google la treaba, si iata am si gasit solutia pe blogul lui Nathan Rice:
In [wordpress root]/includes/functions.php se va introduce urmatoarea functie, intre tagurile <?php si ?>:
function csv_tags() {
$posttags = get_the_tags();
foreach((array)$posttags as $tag) {
$csv_tags .= $tag->name . ',';
}
echo '<meta name="keywords" content="'.$csv_tags.'" />';
}
… iar in [wordpress root]/wp_content/themes/[tema ta WordPress]/header.php se va introduce (de preferinta deasupra tag-ului <title>):
<?php if (is_single() || is_page() ) : if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<meta name="description" content="<?php the_excerpt_rss(); ?>" />
<?php csv_tags(); ?>
<?php endwhile; endif; elseif(is_home()) : ?>
<meta name="description" content="<?php bloginfo('description'); ?>" />
<?php endif; ?>
Sau daca vreai sa folosesti META Keywords si pentru prima pagina, foloseste varianta de mai jos:
<?php if (is_single() || is_page() ) : if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<meta name="description" content="<?php the_excerpt_rss(); ?>" />
<?php csv_tags(); ?>
<?php endwhile; endif; elseif(is_home()) : ?>
<meta name="description" content="<?php bloginfo('description'); ?>" />
<meta name="keywords" content="lista,cuvintelor,cheie,potrivite" />
<?php endif; ?>
Am testat… chiar functioneaza. L-am implementat chiar pe acest blog. Verificati sursa acestui post.
PS: Atentie! La urmatorul update, fisierul functions.php va fi scris deasupra! Nu uita sa reintroduci functia
Multumiri pentru acest hack ca lumea lui Nathan Rice. Keep up the good work and thanks!
Related posts:
Tags: Hack, header, meta, modificare, SEO, tag, vezi ca merge!, WordPress