File: /var/www/Application/wp-content/themes/zoomy/course-results.php
<?php
/**
* Template Name: Course Result
*/
get_header();
/**
* Prevent loading this file directly
*/
defined( 'ABSPATH' ) || exit();
wp_enqueue_style( 'nice-select' );
wp_enqueue_script( 'nice-select' );
global $wp_query;
global $paged;
$temp = $wp_query;
$wp_query = null;
$wp_query = new WP_Query();
$tax_query = array();
if(!empty($_GET['course_category'])) {
$tax_query = array(
array(
'taxonomy' => 'course_category',
'field' => 'slug',
'terms' => $_GET['course_category'],
)
);
}
$wp_query = new WP_Query( array(
'post_type' => 'lp_course',
'posts_per_page' => -1,
'paged' => $paged,
's' => $_GET['keyword_by'] ?? '',
'tax_query' => $tax_query
) );
$total = $wp_query->found_posts;
if ( $total == 0 ) {
$message = '<p class="message message-error">' . esc_html__( 'No courses found!', 'zoomy' ) . '</p>';
$index = esc_html__( 'There are no available courses!', 'zoomy' );
} elseif ( $total == 1 ) {
$index = esc_html__( 'Showing only one result', 'zoomy' );
} else {
$courses_per_page = absint( LP()->settings->get( 'archive_course_limit' ) );
$from = 1 + ( $paged - 1 ) * $courses_per_page;
$to = ( $paged * $courses_per_page > $total ) ? $total : $paged * $courses_per_page;
if ( $from == $to ) {
$index = sprintf(
esc_html__( 'Showing last course of %s results', 'zoomy' ),
$total
);
} else {
$index = sprintf(
esc_html__( 'Showing %s-%s of %s results', 'zoomy' ),
$from,
$to,
$total
);
}
}
?>
<div <?php post_class('page_wrapper'); ?>>
<div class="container">
<div class="archive-course-filter mt-60 mb-40">
<div class="row">
<div class="col-md-6">
<p class="text-index-result"> <?php echo esc_html( $index ); ?> </p>
</div>
<div class="col-md-6 d-inline-flex justify-content-end align-items-center z-text-sm-center">
<strong class="me-2"> <?php echo esc_html__( 'Filter By : ', 'zoomy' ); ?> </strong>
<?php get_template_part( 'learnpress/filter-category-dropdown' ); ?>
</div>
</div>
</div>
<div class="course-archive-wrapper">
<?php
if ( $wp_query->have_posts() ) :
?>
<div class="row">
<?php
while ( $wp_query->have_posts() ) : $wp_query->the_post();
get_template_part( 'learnpress/content-course', 'archive' );
endwhile;
?>
<div class="pagination-area col-lg-12 content-align-center text-center mt-40 mb-60">
<?php
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var( 'paged' ) ),
'total' => $wp_query->max_num_pages,
'prev_text' => '<i class="fas fa-chevron-left"></i>',
'next_text' => '<i class="fas fa-chevron-right"></i>'
) );
?>
</div>
</div>
<?php
endif;
wp_reset_postdata();
?>
</div>
</div>
</div>
<?php
get_footer();