구글뉴스사이트맵 관련문의입니다. 채택완료
현재 그누5에는 구글뉴스사이트맵이 있는데요. 이거를 그누4용도로 할려고합니다.
어떻게 해야될까요???
소스첨부합니다...
<?php
</urlset>
// please give feedbacks to bomool.net
include_once("_common.php");</p><p>$charset = $g5[charset];
$url = "<a href="<a href="http://news.su-wan.com" target="_blank" rel="noopener noreferrer">http://news.su-wan.com</a>"><a href="http://news.su-wan.com" target="_blank" rel="noopener noreferrer">http://news.su-wan.com</a></a>"; //::::::::::::::: write your GNUboard root path</p><p>// 특수문자 변환. 변환하지않으면 XML 문법에 맞지 않으니까 변환해야합니다.
function specialchars_replace($str, $len=0) {
if ($len) { // 두번째 인자로 길이 값을 주면 그 길이만큼만 잘르고 나머지는 버린 후 치환합니다
$str = substr($str, 0, $len);
}</p><p> // 정규식으로 치환해야 제대로 원하는 것만 치환시키겠죠..</p><p> $str = preg_replace("/&/", "&", $str);
$str = preg_replace("/</", "<", $str);
$str = preg_replace("/>/", ">", $str);
return $str;
}</p><p>header("Content-type: text/xml;charset=\"UTF-8\"");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");</p><p>echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";</p><p>?>
<urlset xmlns:news="<a href="<a href="http://www.google.com/schemas/sitemap-news/0.9" target="_blank" rel="noopener noreferrer">http://www.google.com/schemas/sitemap-news/0.9</a>"><a href="http://www.google.com/schemas/sitemap-news/0.9" target="_blank" rel="noopener noreferrer">http://www.google.com/schemas/sitemap-news/0.9</a></a>">
<?php
$query = sql_query("select bo_table from `$g5[board_table]` where bo_read_level='1'");
while($temp = sql_fetch_array($query)) {
$bo_arr[] = $temp[bo_table];
}</p><p>$i = 1;
foreach($bo_arr as $bo) {
$query = sql_query("select wr_id, wr_datetime, wr_subject from `$g5[write_prefix]$bo` where wr_is_comment='0' AND wr_option NOT LIKE '%secret%'");
while($row = sql_fetch_array($query)) {
// list of bo_table
echo "<url>\n";
echo "<loc>$url/bbs/board.php?bo_table=$bo&wr_id=$row[wr_id]</loc>\n";
$temp = sql_fetch("select wr_datetime from `$g5[write_prefix]$bo` where wr_parent='$row[wr_id]' order by wr_id DESC");
$lastmod = str_replace(" ", "T", substr($temp[wr_datetime], 0, 30))."+00:00";
if(!$lastmod) {
$temp = sql_fetch("select wr_datetime from `$g5[write_prefix]$bo` where wr_id='$row[wr_id]'");
$lastmod = str_replace(" ", "T", substr($temp[wr_datetime], 0, 30))."+00:00";
}
if(!$lastmod) $lastmod = $g5[time_ymd];
echo "<<a href="news:news>\n">news:news>\n</a>";
echo "<<a href="news:publication>\n">news:publication>\n</a>";
echo "<<a href='news:name>".specialchars_replace("수완뉴스")."</news:name>\n'>news:name>".specialchars_replace("수완뉴스")."</news:name>\n</a>";
echo "<<a href='news:language>".specialchars_replace("ko")."</news:language>\n'>news:language>".specialchars_replace("ko")."</news:language>\n</a>";
echo "</news:publication>\n";
echo "<<a href='news:publication_date>".specialchars_replace("$lastmod")."</news:publication_date>\n'>news:publication_date>".specialchars_replace("$lastmod")."</news:publication_date>\n</a>";
echo "<title>".specialchars_replace('['.$board['bo_subject'].'] '.$row['wr_subject'])."</title>\n";
echo " </news:news>\n";
echo "</url>\n";</p><p> }
$i++;
}
?>
</urlset></p><p>
답변 3개
답변에 대한 댓글 4개
구글 검색 하셔서 xml을 html로 출력하도록 변환 하셔야 겠네요.
Sitemap 또는 Sitemap 색인 파일에 네임스페이스가 올바로 명시되어 있지 않습니다.
사이트맵 또는 사이트맵 색인 파일에서 필요한 네임스페이스(http://www.sitemaps.org/schemas/sitemap/0.9)를 선언하지 않습니다.
태그: urlset
사이트맵 또는 사이트맵 색인 파일에서 필요한 네임스페이스(http://www.google.com/schemas/sitemap-news/0.9)를 선언하지 않습니다.
상위 태그: news
태그: title
댓글을 작성하려면 로그인이 필요합니다.
질문자님께서 올리신 코드 작성자입니다.
그누보드4에서 작동하는 코드이고
작성한지 10년 넘은 코드라
지금 사용하려면 상당 부분을 커스트마이징해야 할 것입니다.
하지만 최근 구글의 뉴스 알고리즘 정책 변경으로,
자동으로 게시자 페이지가 생성되는 방식이 적용되고
'피드 등록 방식'은 더 이상 사용되지 않습니다.
이 질문글의 코드를 보고 사용하려는 분들께 참고가 되셨으면 해서 올립니다.
감사합니다.
댓글을 작성하려면 로그인이 필요합니다.
https://support.google.com/news/publisher/answer/74288?hl=ko">https://support.google.com/news/publisher/answer/74288?hl=ko
구글뉴스등록할때 사용하라는 xml인데.. 이거를 적용해서 한게 저위에 소스인데... 왜안될까요???
답변에 대한 댓글 1개
https://support.google.com/webmasters/answer/183669
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
근데 urlset 이 윗부분도 닫혀 있네요?