네이버 meta 검색 잘 걸리게 하기
네이버에서 검색 정책이 바뀌어서 meta 랑 RSS 노가다를 해 줘야 하는 상황이라서
meta 먼저 작업을 간단히 하면 테마 폴더 아래에 head.sub.php 에 소스
<meta charset="utf-8"> 여기 하단에 아래 코드를 추가 한다.
<?php
$it_id = $_REQUEST['it_id'];
$http_host = $_SERVER['HTTP_HOST'];
$request_uri = $_SERVER['REQUEST_URI'];
$ogUrl = 'https://' . $http_host . $request_uri;
$sql = "select * from g5_shop_item where it_id='$it_id'";
$result = sql_query($sql); // 쿼리 실행
while ($row = sql_fetch_array($result)) {
//print_r2($row);
$ogTitle = $row['it_name'];
$it_img1 = $row['it_img1'];
}
//쿼리 value 값 가져오기
if(!$ogType) {
$ogType = 'website';
}
$ogImage = get_it_image($it_id, 300,300);
?>
<meta property="og:url" content="<?php echo $ogUrl; ?>" />
<meta property="og:type" content="<?php echo $ogType; ?>" />
<meta property="og:title" content="<?php echo $ogTitle; ?>"/>
<meta property="og:image" content="<?php echo $ogImage; ?>"/>
이거 하면 요런식으로 실제 소스에 추가가 되는걸 볼수 있다.

댓글 12개
감사합니다.
좋은정보 감사합니다.
meta 속성 중 og:image 의 value 는 img 태그가 포함된 값이 들어가는게 아니라, 이미지 경로만 들어가야 합니다.
아래와 같이 해야 할것 같네요.
그리고 it_id가 있을때에만 데이터가 조회되기에 조건으로 감싸야 할것 같은데요.
<?php
if($_REQUEST['it_id'] != ""){
$it_id = $_REQUEST['it_id'];
$http_host = $_SERVER['HTTP_HOST'];
$request_uri = $_SERVER['REQUEST_URI'];
$ogUrl = 'https://' . $http_host . $request_uri;
$sql = "select * from g5_shop_item where it_id='$it_id'";
$result = sql_query($sql); // 쿼리 실행
while ($row = sql_fetch_array($result)) {
//print_r2($row);
$ogTitle = $row['it_name'];
$it_img1 = $row['it_img1'];
}
//쿼리 value 값 가져오기
if(!$ogType) {
$ogType = 'website';
}
//$ogImage = get_it_image($it_id, 300,300);
$ogImage = get_it_imageurl($it_id);
?>
<meta property="og:url" content="<?php echo $ogUrl; ?>" />
<meta property="og:type" content="<?php echo $ogType; ?>" />
<meta property="og:title" content="<?php echo $ogTitle; ?>"/>
<meta property="og:image" content="<?php echo $ogImage; ?>"/>
<?php } ?>
@붉은바람 자세한 추가 조언 감사합니다.
좋은정보 감사합니다.
while ( 은 무한 루프 입니다. 이것만 빼주면 좋은 소스 인거같아요
네이버 메타 검색
감사합니다
<?php
if($_REQUEST['it_id'] != ""){
$it_id = $_REQUEST['it_id'];
$http_host = $_SERVER['HTTP_HOST'];
$request_uri = $_SERVER['REQUEST_URI'];
$ogUrl = 'https://' . $http_host . $request_uri;
$sql = "select * from g5_shop_item where it_id='$it_id'";
$result = sql_query($sql); // 쿼리 실행
while ($row = sql_fetch_array($result)) {
//print_r2($row);
$ogTitle = $row['it_name'];
$it_img1 = $row['it_img1'];
}
//쿼리 value 값 가져오기
if(!$ogType) {
$ogType = 'website';
}
//$ogImage = get_it_image($it_id, 300,300);
$ogImage = get_it_imageurl($it_id);
?>
<meta property="og:url" content="<?php echo $ogUrl; ?>" />
<meta property="og:type" content="<?php echo $ogType; ?>" />
<meta property="og:title" content="<?php echo $ogTitle; ?>"/>
<meta property="og:image" content="<?php echo $ogImage; ?>"/>
<?php } ?>
if($_REQUEST['it_id'] != ""){
$it_id = $_REQUEST['it_id'];
$http_host = $_SERVER['HTTP_HOST'];
$request_uri = $_SERVER['REQUEST_URI'];
$ogUrl = 'https://' . $http_host . $request_uri;
$sql = "select * from g5_shop_item where it_id='$it_id'";
$result = sql_query($sql); // 쿼리 실행
while ($row = sql_fetch_array($result)) {
//print_r2($row);
$ogTitle = $row['it_name'];
$it_img1 = $row['it_img1'];
}
//쿼리 value 값 가져오기
if(!$ogType) {
$ogType = 'website';
}
//$ogImage = get_it_image($it_id, 300,300);
$ogImage = get_it_imageurl($it_id);
?>
<meta property="og:url" content="<?php echo $ogUrl; ?>" />
<meta property="og:type" content="<?php echo $ogType; ?>" />
<meta property="og:title" content="<?php echo $ogTitle; ?>"/>
<meta property="og:image" content="<?php echo $ogImage; ?>"/>
<?php } ?>
감사합니다
감사합니다
게시판 목록
영카트5 팁자료실
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 431 | 2개월 전 | 137 | ||
| 430 | 2개월 전 | 164 | ||
| 429 | 2개월 전 | 195 | ||
| 428 |
선택과집중
|
2개월 전 | 239 | |
| 427 |
선택과집중
|
3개월 전 | 389 | |
| 426 |
비버팩토리
|
3개월 전 | 360 | |
| 425 |
선택과집중
|
3개월 전 | 266 | |
| 424 |
선택과집중
|
3개월 전 | 396 | |
| 423 |
선택과집중
|
3개월 전 | 364 | |
| 422 |
선택과집중
|
3개월 전 | 331 | |
| 421 |
선택과집중
|
4개월 전 | 383 | |
| 420 | 4개월 전 | 422 | ||
| 419 |
선택과집중
|
4개월 전 | 364 | |
| 418 |
세르반데스
|
4개월 전 | 329 | |
| 417 |
선택과집중
|
4개월 전 | 417 | |
| 416 |
선택과집중
|
4개월 전 | 329 | |
| 415 |
선택과집중
|
5개월 전 | 362 | |
| 414 |
선택과집중
|
5개월 전 | 378 | |
| 413 |
선택과집중
|
5개월 전 | 463 | |
| 412 |
선택과집중
|
6개월 전 | 405 | |
| 411 |
선택과집중
|
6개월 전 | 316 | |
| 410 |
다케미카코
|
8개월 전 | 830 | |
| 409 |
다케미카코
|
8개월 전 | 583 | |
| 408 | 8개월 전 | 567 | ||
| 407 |
|
10개월 전 | 926 | |
| 406 | 11개월 전 | 1018 | ||
| 405 |
|
11개월 전 | 557 | |
| 404 | 1년 전 | 1273 | ||
| 403 | 1년 전 | 744 | ||
| 402 | 1년 전 | 777 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기