サポート » 使い方全般 » ユーザー紹介ページ(author.php)について

  • ユーザー紹介ページで寄稿者が一覧表示されれるようになっています。
    寄稿者のみを表示したいのですが、管理者も表示されてしまいます。
    管理者を表示させないようにするにはどうすればいいでしょうか?

    下記が記述しているコードです。

    author-list.php

    // Import require functions
    require_once(DP_THEME_DIR . "/inc/scr/get_author_info.php");
    
    <div class="archive-title-sec author authors-list">
    <ul class="authors_list<?php echo $col_class; ?>">
    <?php
    	// Params
    	$args = array('return_array'=> true,
    				'is_microdata' 	=> false,
    
    				'avatar_size' 	=> 300);
    	foreach ( $query as $q ) :
    		$args['user_id'] = $q->ID;
    		$arr_author 	= dp_get_author_info($args);
    		$author_code 	= $arr_author['profile_img'].$arr_author['author_role'].'<a href="'.$arr_author['author_posts_url'].'">'.$arr_author['author_name'].'</a>';
    
    ?>
    <li class="author_item clearfix"><?php echo $author_code; ?></li>
    <?php
    	endforeach;
    ?>
    </ul>
    </div>

    get_author_info.php

    function dp_get_author_posts() {
    	global $post, $options, $options_visual, $COLUMN_NUM, $IS_MOBILE_DP;
    
    	if (post_password_required()) return;
    
    	$post_num 	= 4;
    	$width 		= 400;
    	$height 	= 320;
    	$cats 		= '';
    	$cats_code 	= '';
    	$more_code 	= '';
    	$articles_code = '';
    
    // Params
    	$args = array(
    			'author'=> ('ID'),
    			'numberposts'=> $post_num,
    			'exclude'=> $post->ID
    			);
    // Get posts
    	$articles =  get_posts($args);
    }

    アドバイスをお願いいたします。

2件の返信を表示中 - 1 - 2件目 (全2件中)
  • モデレーター jim912

    (@jim912)

    寄稿者を一覧表示しているのは、author.php でしょうか。

    この場合、author-list.php との関係はどうなっていますか?
    また、get_author_info.php に記述されている dp_get_author_posts は、他に記述がありませんので、すくなくともご提示いただいた箇所では利用されていないようです。

    コードから察するに、author-list.php の $query にユーザーが格納されているのではと思われますが、$query についても、この1箇所でしか登場してないため、ユーザーの取得部分が一切分かりません。

    もう少し情報提供をお願いします。

    トピック投稿者 tdf765

    (@tdf765)

    jim912さんご返信ありがとうございます。

    申し訳ございません、寄稿者を一覧表示しているのは、author-list.phpになります。
    dp_get_author_postsは利用されていないとのことで、ありがとうございます。

    $queryについて、atuthor-list.phpに下記の記述があります。

    // Author params in current page
    $number 	= 24;
    $paged 		= (get_query_var('paged')) ? get_query_var('paged') : 1;
    $offset 	= ($paged - 1) * $number;
    $users 		= get_users(array('orderby'=>ID,'exclude'=>'1'));
    $query 		= get_users('&offset='.$offset.'&number='.$number);
    $total_users = count($users);
    $total_query = count($query);
    $total_pages = intval($total_users / $number) + 1;

    $userから’exclude’を使用して除外すればいいのかなと考えていたので、上手くいかず困っていました。

    よろしくお願いします。

2件の返信を表示中 - 1 - 2件目 (全2件中)
  • トピック「ユーザー紹介ページ(author.php)について」には新たに返信することはできません。