아래코드는 그누보드 게시물 메타 태그 자동 생성해줍니다.
[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개
게시글 목록
| 번호 | 제목 |
|---|---|
| 23966 | |
| 23963 | |
| 23953 | |
| 23949 | |
| 23938 | |
| 23935 | |
| 23933 | |
| 23928 | |
| 23919 | |
| 23918 | |
| 23917 | |
| 23910 | |
| 23902 | |
| 23901 | |
| 23897 | |
| 23894 | |
| 23893 | |
| 23891 | |
| 23885 | |
| 23872 | |
| 23870 | |
| 23862 | |
| 23859 | |
| 23853 | |
| 23845 | |
| 23838 | |
| 23827 | |
| 23819 | |
| 23805 | |
| 23801 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기