지난 자료들 찾아서 카테고리 옆에 개수를 표시하는 방법을 찾아서 잘 적용하였습니다.
<div class="kboard-category category-pc">
<?php if($board->initCategory1()):?>
<?php $category_count = $board->getCategoryCount(array('category1'=>''))?>
<ul class="kboard-category-list">
<li<?php if(!kboard_category1()):?> class="kboard-category-selected"<?php endif?>><a href="<?php echo $url->set('category1', '')->set('pageid', '1')->set('target', '')->set('keyword', '')->set('mod', 'list')->tostring()?>"><?php echo __('All', 'kboard')?><?php if($category_count):?>(<?php echo $category_count?>)<?php endif?></a></li>
<?php while($board->hasNextCategory()):?>
<?php $category_count = $board->getCategoryCount(array('category1'=>$board->currentCategory()))?>
<li<?php if(kboard_category1() == $board->currentCategory()):?> class="kboard-category-selected"<?php endif?>>
<a href="<?php echo $url->set('category1', $board->currentCategory())->set('pageid', '1')->set('target', '')->set('keyword', '')->set('mod', 'list')->toString()?>"><?php echo $board->currentCategory()?><?php if($category_count):?>(<?php echo $category_count?>)<?php endif?></a>
</li>
<?php endwhile?>
</ul>
<?php endif?>
위와 같이 적용하니 모든 작성자의 개수가 나오던데
작성자의 글 개수만 표시할수 있나요?
기본적으로 본인의 글만 보기로 설정하였습니다.
안녕하세요~^^
게시판에서 작성자의 게시글만 보이게 하려면
올려주신 코드를 아래의 코드로 변경해보시겠어요?
<div class="kboard-category category-pc">
<?php
global $wpdb;
$current_user_id = get_current_user_id();
$board_id = $board->id;
$user_content_count = $wpdb->get_var("SELECT COUNT(*) FROM `{$wpdb->prefix}kboard_board_content` WHERE `board_id` = '{$board_id}' And `member_uid` = '{$current_user_id}'");
?>
<?php if($board->initCategory1()):?>
<ul class="kboard-category-list">
<li <?php if(!kboard_category1()):?> class="kboard-category-selected"<?php endif?>><a href="<?php echo $url->set('category1', '')->set('pageid', '1')->set('target', '')->set('keyword', '')->set('mod', 'list')->tostring()?>"><?php echo __('All', 'kboard')?><?php if(is_user_logged_in()){echo '('. $user_content_count . ')';}?></a></li>
<?php while($board->hasNextCategory()):?>
<li <?php if(kboard_category1() == $board->currentCategory()):?> class="kboard-category-selected"<?php endif?>>
<?php $count_category = $board->currentCategory()?>
<?php $user_category_content_count = $wpdb->get_var("SELECT COUNT(*) FROM `{$wpdb->prefix}kboard_board_content` WHERE `board_id` = '{$board_id}' And `member_uid` = '{$current_user_id}' AND `category1` LIKE '{$count_category}'")?>
<a href="<?php echo $url->set('category1', $board->currentCategory())->set('pageid', '1')->set('target', '')->set('keyword', '')->set('mod', 'list')->toString()?>"><?php echo $board->currentCategory()?><?php if(is_user_logged_in()){echo '('. $user_category_content_count . ')';}?></a>
</li>
<?php endwhile?>
</ul>
<?php endif?>
위 코드로 변경 시 로그인 한 유저에게만 작성한 글 수가 출력됩니다.
고맙습니다.