['forum', 'topic' ],
's' => $_POST['keyword'] ?? '',
) );
$all_results_count = $all_results->found_posts;
if ( $all_results_count > 0 ) {
$all_nsoresult = 'data-result=';
} else {
$all_nsoresult = 'data-noresult=';
}
// Forum query
$forum_query = new WP_Query( array(
'post_type' => ['forum', 'topic'],
's' => $_POST['keyword'] ?? '',
) );
$forum_count = $forum_query->found_posts;
if ( $forum_count > 0 ) {
$forum_nsoresult = 'data-result=';
} else {
$forum_nsoresult = 'data-noresult=';
}
?>
>
class="tab-item" >
';
// Forums query
if ( class_exists( 'bbPress' ) ) :
echo '';
$forum = new WP_Query( array(
'post_type' => 'forum',
's' => $_POST['keyword'] ?? '',
'posts_per_page' => 5,
) );
if ( $forum->have_posts() ) :
echo '
' . esc_html__( 'Forums', 'bbp-core' ) . '
';
while ( $forum->have_posts() ) : $forum->the_post();
?>
'topic',
's' => $_POST['keyword'] ?? '',
'posts_per_page' => 5,
) );
if ( $topics->have_posts() ) :
echo '
' . esc_html__( 'Topics', 'bbp-core' ) . '
';
while ( $topics->have_posts() ) : $topics->the_post();
?>
';
endif;
echo '
Not Found Result!
';
echo '
';
die();
}
/**
* Forum Search results
*/
add_action( 'wp_ajax_bbpc_search_data_forum', 'bbpc_search_data_forum' );
add_action( 'wp_ajax_nopriv_bbpc_search_data_forum', 'bbpc_search_data_forum' );
function bbpc_search_data_forum() {
// Forums query
if ( class_exists( 'bbPress' ) ) :
echo '';
$forum = new WP_Query( array(
'post_type' => 'forum',
's' => $_POST['keyword'] ?? '',
'posts_per_page' => 5,
) );
if ( $forum->have_posts() ) :
echo '
' . esc_html__( 'Forums', 'bbp-core' ) . '
';
while ( $forum->have_posts() ) : $forum->the_post();
?>
'topic',
's' => $_POST['keyword'] ?? '',
'posts_per_page' => 5,
) );
if ( $topics->have_posts() ) :
echo '
' . esc_html__( 'Topics', 'bbp-core' ) . '
';
while ( $topics->have_posts() ) : $topics->the_post();
?>
';
endif;
die();
}