<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
	<channel>
				<title><![CDATA[게시판 이전글 다음글 수정 관련]]></title>
		<link>https://www.cosmosfarm.com/threads/rss/document/13325</link>
		<description><![CDATA[<p><a href="http://www.cosmosfarm.com/threads/document/10754" target="_blank">http://www.cosmosfarm.com/threads/document/10754</a></p>

<p>검색하다 여기 글을 보고 문의드립니다.</p>

<p>코드를 보면 답변 주신대로 uid 값이 기준이 되는 거 같은데</p>

<p>이걸 date나 update로 변경하는 방법에 대해 조언 좀 부탁드립니다...!</p>
]]></description>
		<copyright>Copyright 2026, 코스모스팜</copyright>
				<item>
			<title><![CDATA[감사합니다.

참고해서 적용토록 하겠습니다!
]]></title>
			<link>https://www.cosmosfarm.com/threads/document/13335</link>
			<description><![CDATA[<p>감사합니다.</p>

<p>참고해서 적용토록 하겠습니다!</p>
]]></description>
			<author>자바칩스크립트</author>
			<pubDate>Thu, 20 Apr 2017 08:12:07 +0000</pubDate>
			<category>KBoard</category>
		</item>
				<item>
			<title><![CDATA[먼저 아래 코드를 테마의 functions.php 파일에 추가해주세요.


function get_next_content_uid($board...]]></title>
			<link>https://www.cosmosfarm.com/threads/document/13333</link>
			<description><![CDATA[<p>먼저 아래 코드를 테마의 functions.php 파일에 추가해주세요.</p>

<pre class="brush:php;toolbar:false;">
function get_next_content_uid($board_id, $current_uid, $key, $value){
	global $wpdb;
	
	$board_id = intval($board_id);
	$current_uid = intval($current_uid);
	$key = esc_sql(sanitize_key($key));
	$value = esc_sql(sanitize_text_field($value));
	
	$where[] = "`board_id`='{$board_id}'";
	$where[] = "`uid`!='{$current_uid}'";
	$where[] = "`$key`&gt;='{$value}'";
	
	// 휴지통에 없는 게시글만 불러온다.
	$where[] = "(`status`='' OR `status` IS NULL OR `status`='pending_approval')";
	
	$category1 = kboard_category1();
	$category2 = kboard_category2();
	
	if($category1){
		$category1 = esc_sql($category1);
		$where[] = "`category1`='{$category1}'";
	}
	if($category2){
		$category2 = esc_sql($category2);
		$where[] = "`category2`='{$category2}'";
	}
	
	$where = implode(' AND ', $where);
	$uid = $wpdb-&gt;get_var("SELECT `uid` FROM `{$wpdb-&gt;prefix}kboard_board_content` WHERE {$where} ORDER BY `{$key}` ASC LIMIT 1");
	
	return intval($uid);
}

function get_prev_content_uid($board_id, $current_uid, $key, $value){
	global $wpdb;
	
	$board_id = intval($board_id);
	$current_uid = intval($current_uid);
	$key = esc_sql(sanitize_key($key));
	$value = esc_sql(sanitize_text_field($value));
	
	$where[] = "`board_id`='{$board_id}'";
	$where[] = "`uid`!='{$current_uid}'";
	$where[] = "`$key`&lt;='{$value}'";
	
	// 휴지통에 없는 게시글만 불러온다.
	$where[] = "(`status`='' OR `status` IS NULL OR `status`='pending_approval')";
	
	$category1 = kboard_category1();
	$category2 = kboard_category2();
	
	if($category1){
		$category1 = esc_sql($category1);
		$where[] = "`category1`='{$category1}'";
	}
	if($category2){
		$category2 = esc_sql($category2);
		$where[] = "`category2`='{$category2}'";
	}
	
	$where = implode(' AND ', $where);
	$uid = $wpdb-&gt;get_var("SELECT `uid` FROM `{$wpdb-&gt;prefix}kboard_board_content` WHERE {$where} ORDER BY `{$key}` DESC LIMIT 1");
	
	return intval($uid);
}</pre>

<p> </p>

<p>그 다음 게시판 스킨의 document.php 파일을 수정해주세요.</p>

<p>$bottom_content_uid = $content-&gt;getPrevUID();</p>

<p>위 코드를 찾아서 아래 코드로 바꿔주세요.</p>

<p>$bottom_content_uid = get_prev_content_uid($board-&gt;id, $content-&gt;uid, 'date', $content-&gt;date);</p>

<p> </p>

<p>마찬가지로</p>

<p>$top_content_uid = $content-&gt;getNextUID();</p>

<p>위 코드를 찾아서 아래 코드로 바꿔주세요.</p>

<p>$top_content_uid = get_next_content_uid($board-&gt;id, $content-&gt;uid, 'date', $content-&gt;date);</p>

<p> </p>

<p>아래처럼 사용하시면 update 기준으로 이전글 다음글의 uid값을 가져올 수 있습니다.</p>

<p>$bottom_content_uid = get_prev_content_uid($board-&gt;id, $content-&gt;uid, 'update', $content-&gt;update);</p>

<p>$top_content_uid = get_next_content_uid($board-&gt;id, $content-&gt;uid, 'update', $content-&gt;update);</p>
]]></description>
			<author>스레드봇</author>
			<pubDate>Thu, 20 Apr 2017 07:37:43 +0000</pubDate>
			<category>KBoard</category>
		</item>
			</channel>
</rss>