Senin, 09 Desember 2013

Browse Manual » Wiring » » » » » » Setting SEO Tanpa Plugin SEO Wordpress

Setting SEO Tanpa Plugin SEO Wordpress

Timbul pertanyaan, "Setting SEO Tanpa Plugin SEO Wordpress?". Wah beruntung ada temen yang berkenan share.  Kuncinya Edit Function.php masukan Kode Berikut:

function meta_seo() {
 $desc_length = 30;
 $use_excerpt = 1;
 $key = diskripsi;
 global $cat, $cache_categories, $wp_query, $wp_version;
 if((is_single() || is_page())&& !is_attachment()) {
 $post = $wp_query->post;
 $post_custom = get_post_custom($post->ID);
 $custom_desc_value = $post_custom["$key"][0];
 if($custom_desc_value) {
 $text = $custom_desc_value;
 } elseif($use_excerpt && !empty($post->post_excerpt)) {
 $text = $post->post_excerpt;
 } else {
 $text = $post->post_content;
 }
 $text = str_replace(array("
", " ", "
", " "), " ", $text);
 $text = str_replace(array("""), "", $text);
 $text = trim(strip_tags($text));
 $text = explode( , $text);
 if(count($text) > $desc_length) {
 $l = $desc_length;
 $more = ...;
 } else {
 $l = count($text);
 $more = ;
 }
 $description = ;
 for ($i=0; $i<$l; $i++)
 $description .= $text[$i] . ;
 $description .= $more;
 if($description) {
 echo "<meta name="description" content="$description" />
";
 }
 $postTags = get_the_tags();
 if($postTags){
 $tagNames = array();
 foreach($postTags as $tag) {
 $tagNames[] = $tag->name;
 }
 }
 $kiword = implode($tagNames,", ");
 if($kiword) {
 echo "<meta name="keywords" content="$kiword" />
";
 }
 }
 elseif (is_paged() || is_day() || is_tag() || is_search() || is_month() || is_year()) {
 echo "<meta name="robots" content="noindex,follow" />
";
 }
}
Lalu EDIT Header.php, masukan kode berikut:
<?php meta_seo(); ?>
</head>

CATATAN: Woke? jurus Setting SEO Tanpa Plugin SEO Wordpress di ats bekerja ketika postingannya ada tagnya. Kalau misal nggak masukin tag di artikelnya ya akan terjadi eror :).

Tidak ada komentar:

Posting Komentar