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

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

· 10개월 전 · 851 · 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개월 전

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

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

게시글 목록

번호 제목
22569
22566
22565
22559
22530
22527
22525
22521
22518
22506
22500
22490
22487
22481
22480
22473
22471
22468
22453
22449
22440
22436
22435
22415
22407
22404
22376
22364
22362
22353