메타태그 description에 게시물 내용 넣기 정보
메타태그 description에 게시물 내용 넣기
본문
선택 게시판
!-->!-->!-->!-->
<?php
if (in_array($bo_table, ['free', 'gallery']) && $wr_id) {
$description = cut_str(strip_tags(preg_replace('/\s+/', ' ', str_replace('"', '"', $write['wr_content']))), 200);
} else {
$description = "원하는 문구";
}
?>
<meta name="description" content="<?php echo $description; ?>" />
모든 게시판
<?php
$description = $wr_id ? cut_str(strip_tags(preg_replace('/\s+/', ' ', str_replace('"', '"', $write['wr_content']))), 200) : "원하는 문구";
?>
<meta name="description" content="<?php echo $description; ?>" />
Q&A 보다가 순정에서 쓰던게 생각나서 함 올려봅니다.
추가 사항
https://sir.kr/g5_tip/23317
@ideaman 님 요청으로 위 @비타주리 님 팁에 적용
선택 게시판
add_event('common_header', function() {
global $config, $bo_table, $wr_id, $write;
if (in_array($bo_table, ['free', 'gallery']) && $wr_id) {
$description = cut_str(strip_tags(preg_replace('/\s+/', ' ', str_replace('"', '"', $write['wr_content']))), 200);
} else {
$description = "원하는 문구";
}
$config['cf_add_meta'] .= '
<meta name="description" content="'.$description.'">
';
});
모든 게시판
add_event('common_header', function() {
global $config, $bo_table, $wr_id, $write;
$description = $wr_id ? cut_str(strip_tags(preg_replace('/\s+/', ' ', str_replace('"', '"', $write['wr_content']))), 200) : "원하는 문구";
$config['cf_add_meta'] .= '
<meta name="description" content="'.$description.'">
';
});
추천
9
9
댓글 8개

감사 합니다.

@들레아빠 추천감사합니다^^

앗 혹시 제 질문글을 보신건가용 ㅋㅋ

@ideaman 넵^^

@푸른산타 훅? 으로 하는 방법 없나요 ㅎㅎ 훅버전 만들어주세요 기존 훅 팁에 적용하니 에러가 나더라구요 ㅠㅠ


추천합니다. 유용합니다. 최고입니다.

@비타주리 님 팁이 최곱니다.
전 살짝 숟가락만 얻은거죠^^;