아래코드는 그누보드 게시물 메타 태그 자동 생성해줍니다.
[code]
<?php
// head.php 혹은 head.sub.php의 <head> 부분에 아래 코드를 추가합니다.
// 페이지 종류에 따라 메타 정보 결정
if (defined('G5_IS_VIEW')) {
// 1. 게시글 상세보기 페이지인 경우
// 게시글 제목 (예: $view['wr_subject']는 게시글 제목을 담고 있다고 가정)
$meta_title = isset($view['wr_subject']) ? $view['wr_subject'] : $config['cf_title'];
// 게시글 내용에서 HTML 태그 제거 후 요약 (최대 160자)
if (isset($view['wr_content'])) {
$content = strip_tags($view['wr_content']);
$meta_description = mb_substr($content, 0, 160, 'UTF-8');
} else {
$meta_description = $config['cf_content'];
}
// 게시글에 태그(키워드)가 입력되어 있다면 이를 사용
$meta_keywords = isset($view['wr_tags']) ? $view['wr_tags'] : '';
} else {
// 2. 목록, 메인 페이지 등 기타 페이지인 경우
$meta_title = $config['cf_title']; // 예: 사이트 기본 제목
$meta_description = "기본설명 입력"; // 예: 사이트 기본 설명
$meta_keywords = "키워드입력"; // 예: 사이트 기본 키워드
}
?>
<!-- 메타 태그 출력 -->
<meta name="title" content="<?php echo htmlspecialchars($meta_title); ?>">
<meta name="description" content="<?php echo htmlspecialchars($meta_description); ?>">
<meta name="keywords" content="<?php echo htmlspecialchars($meta_keywords); ?>">
[/code]
댓글 5개
게시글 목록
| 번호 | 제목 |
|---|---|
| 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 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기