Share seo cho wblib, tự động chèn description

Admin

AdminAdmin is verified member.

Well-Known Member
Staff member
Administrator
Như anh em đã biết thì wblib nó ko thay đổi description cho mỗi bài viết mà chỉ sử dụng trong cài đặt ở admin.
Hôm nay mình sẽ hướng dẫn anh em fix lại chút, cái này đơn giản mà chưa ai làm


Vào inc/func.php thêm đoạn code sau

#####
function xemtruoc ( $str, $length) {
if (strstr($str,'
Code:
')) return ''; 
  $result = substr ( strip\es( $str ), 0, $length ); 
  while( true ) { 
    if( $tmp = substr ( strip\es( $str ), $length, 1 ) ) { 
      if ( $tmp == ' ' ) break; 
      $result .= $tmp; 
    } else break; 
    $length++; 
  } 
  return $result; 
}
##### 


 Sửa file inc/core.php
 Tìm 
 #####
require_once ('func.php');
##### 

 Thêm vào sau:
 #####
if ($id) 
{ 
    $wtf = mysql_fetch_assoc(mysql_query("SELECT `text` FROM `article` WHERE `id` = $id")); 
    $prev = xemtruoc($wtf['text'],200); 
}
##### 


 Sau đó sửa file inc/head.php
 Thay thế
 #####
if (!empty ($set['meta_desc'])) echo '<meta name="description" content="' . $set['meta_desc'] . '" />';
##### 


 bằng
 #####
if (!$prev) echo '<meta name="description" content="'. $set['meta_desc'] .'">'; 
else echo '<meta name="description" content="'.$prev.'">';
#####
 

Facebook Comments

Similar threads

Npnken
Replies
0
Views
2K
Npnken
Npnken
D
Replies
0
Views
15K
diepthaiphu
D
cuongpro9x
Replies
0
Views
4K
cuongpro9xcuongpro9x is verified member.
cuongpro9x
Admin
Replies
0
Views
2K
AdminAdmin is verified member.
Admin
Back
Top