BuddyPress::page_questions( false|int $user_id = false, false $paged = false, false $only_posts = false )

Description #

Callback for rendering questions page.

Parameters #

  • $user_id
    false | int (Optional) User id. Default value: false
  • $paged
    false (Optional) Current paged. Default value: false
  • $only_posts
    false (Optional) Show only posts. Default value: false

Source #

File: addons/buddypress/buddypress.php

	public function page_questions( $user_id = false, $paged = false, $only_posts = false ) {
		$args['ap_current_user_ignore'] = true;
		$args['showposts']              = 10;

		if ( false === $user_id ) {
			$user_id = bp_displayed_user_id();
		}

		$args['author'] = $user_id;

		if ( false !== $paged ) {
			$args['paged'] = $paged;
		}

		/**
		 * FILTER: ap_authors_questions_args
		 * Filter authors question list args
		 *
		 * @var array
		 */
		$args                 = apply_filters( 'ap_bp_questions_args', $args );
		anspress()->questions = new \Question_Query( $args );

		if ( false === $only_posts ) {
			echo '<div class="ap-bp-head clearfix">';
			echo '<h1>' . esc_attr__( 'Questions', 'anspress-question-answer' ) . '</h1>';
			ap_list_filters();
			echo '</div>';
			echo '<div id="ap-bp-questions">';
		}

		if ( ap_have_questions() ) {
			/* Start the Loop */
			while ( ap_have_questions() ) :
				ap_the_question();
				ap_get_template_part( 'buddypress/question-item' );
			endwhile;
		}

		if ( false === $only_posts ) {
			echo '</div>';
		}

		if ( anspress()->questions->max_num_pages > 1 && false === $only_posts ) {
			$args = wp_json_encode(
				array(
					'__nonce' => wp_create_nonce( 'loadmore-questions' ),
					'type'    => 'questions',
					'current' => 1,
					'user_id' => bp_displayed_user_id(),
				)
			);
			echo '<a href="#" class="ap-bp-loadmore ap-btn" ap-loadmore="' . esc_js( $args ) . '">' . esc_attr__( 'Load more questions', 'anspress-question-answer' ) . '</a>';
		}
	}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment