サポート » 使い方全般 » 「BB press」のユーザー別トピック一覧

  • 解決済 puniler

    (@puniler)


    プラグイン「BB press」で、表示中ユーザーが作ったトピック一覧を5件出力するコード、のつもりなのですが…、

    どこが間違っているのか教えて頂けませんでしょうか?

    <?php
    $UID = bp_displayed_user_id();
    ?>
    
    <h2><?php echo $UID; ?>さんのトピック一覧</h2>
    
    <?php
    
    $bbp_loop_args = array(
     'post_parent'    => 77, //フォーラムのIDです
     'post_type'      => 'topic', 
     'posts_per_page' => 5, 
     'comment_count'  => '1', 
     'orderby'        => 'newest',
     'user_id'        => $UID
     );
     
    $BB_Query      = new WP_Query( $bbp_loop_args );
     
    if ( $BB_Query->have_posts() ) {
     
    	$html = '<li class="forum-list"><span class="bbp-topic-started-by"><!--Started by:-->%1$s</span><a class="bbp-forum-topic-title" href="%2$s">%3$s</a><span class="reply-count">%4$d</span></li>';
     
    	?><ul><?php
    	
    	while ( $BB_Query->have_posts() ) {
    		
    		$BB_Query->the_post(); 
     
    		$author_link        = bbp_get_topic_author_link( array( 'post_id' => get_the_ID(), 'type' => 'avatar', 'size' => 32 ) );
    		$avatar_allowd_tags = array( 'a' => array( 'href' => true, 'id' => true, 'class' => true, target => true ),
    					'img' => array( 'src' => true, 'id' => true, 'alt' => true, 'class' => true ),
    				);
    		printf( $html,
    					wp_kses( $author_link, $avatar_allowd_tags ),
    					esc_url( bbp_get_topic_permalink() ),
    					wp_kses( bbp_get_topic_title(),array() ),
    					absint( bbp_get_topic_reply_count( get_the_ID() ) )
    			);
    	} 
    	?></ul><?php
    } 
    wp_reset_query(); 
    ?>
4件の返信を表示中 - 1 - 4件目 (全4件中)
  • こんにちは

    comment_count (コメントパラメータ) によりトピックが取得できていないのではないでしょうか?

    $bbp_loop_args = array(
     'post_parent'    => 77, //フォーラムのIDです
     'post_type'      => 'topic', 
     'posts_per_page' => 5, 
     //'comment_count'  => '1', 
     'orderby'        => 'newest',
     'user_id'        => $UID
     );
    トピック投稿者 puniler

    (@puniler)

    こんにちは!お世話になっております。

    なるほど、'comment_count' => '1',があるとできないのですね。
    (どうしてですか!?)

    ご指摘誠にありがとうございます。

    あとどうやら'user_id' => $UIDも問題だったみたいです。

    この2つを消したら表示されました。

    ただし、目的は「ユーザー別」なので、後者のは消したくないのですが、パラメータの指定方法がわからず、行き詰っております。BBpress公式とかに書いてないものでしょうか?見当たらなくって…

    comment_count (コメントパラメータ) は数字の場合は、コメント数になります。
    https://wpdocs.osdn.jp/関数リファレンス/WP_Query#.E3.82.B3.E3.83.A1.E3.83.B3.E3.83.88.E3.83.91.E3.83.A9.E3.83.A1.E3.83.BC.E3.82.BF

    作成者 (投稿者) であれば、’author’ でしょうか。

    トピック投稿者 puniler

    (@puniler)

    ’author’でした!!ありがとうございます。やっとできました。

4件の返信を表示中 - 1 - 4件目 (全4件中)
  • トピック「「BB press」のユーザー別トピック一覧」には新たに返信することはできません。