테스트 사이트 - 개발 중인 베타 버전입니다

메타태그 description에 게시물 내용 넣기

· 10개월 전 · 844 · 8

선택 게시판
[code]
<?php
if (in_array($bo_table, ['free', 'gallery']) && $wr_id) {
    $description = cut_str(strip_tags(preg_replace('/\s+/', ' ', str_replace('"', '&#34;', $write['wr_content']))), 200);
} else {
    $description = "원하는 문구";
}
?>
<meta name="description" content="<?php echo $description; ?>" />
[/code]

 

모든 게시판
[code]
<?php 
$description = $wr_id ? cut_str(strip_tags(preg_replace('/\s+/', ' ', str_replace('"', '&#34;', $write['wr_content']))), 200) : "원하는 문구";
?>
<meta name="description" content="<?php echo $description; ?>" />
[/code]

 

Q&A 보다가 순정에서 쓰던게 생각나서 함 올려봅니다.

 

추가 사항
https://sir.kr/g5_tip/23317

@ideaman 님 요청으로 위 @비타주리 님 팁에 적용

 

선택 게시판
[code]
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.'">
    ';
});
[/code]

 

모든 게시판
[code]
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.'">
    ';
});
[/code]

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

댓글 8개

10개월 전

감사 합니다.

10개월 전

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

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

10개월 전

@ideaman 넵^^

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

10개월 전

@ideaman 비타주리님 팁에

https://sir.kr/g5_tip/23317

적용 추가 업데이트했어요

10개월 전

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

10개월 전

@비타주리 님 팁이 최곱니다.

전 살짝 숟가락만 얻은거죠^^;

게시글 목록

번호 제목
24318
24317
24315
24309
24294
24293
24277
24262
24260
24253
24251
24236
24233
24228
24226
24221
24214
24203
24201
24199
24196
24195
24194
24192
24191
24187
24185
24183
24172
24168