我希望课程页面能够按价格查询课程...找到了这一点,并希望它能完成工作...
内容存档 course.php
$default_order = apply_filters( 'thim_default_order_course_option', array(
'newly-published' => esc_html__( 'Newly published', 'eduma' ),
'alphabetical' => esc_html__( 'Alphabetical', 'eduma' ),
'most-members' => esc_html__( 'Most members', 'eduma' ),
//'price' => esc_html__( 'Price', 'eduma' )
) );;
还位:learnpress_v3_functions.php
if ( !function_exists( 'thim_course_order_query' ) ) {
function thim_course_order_query( $query ) {
if ( !$query->is_main_query() ) {
return;
}
if ( !is_post_type_archive( 'lp_course' ) && !is_tax( 'course_category' ) ) {
return;
}
// Sort
if ( isset( $_POST['course_orderby'] ) ) {
switch ( $_POST['course_orderby'] ) {
case 'alphabetical':
$query->set( 'orderby', 'title' );
$query->set( 'order', 'ASC' );
break;
case 'most-members':
$query->set( 'orderby', 'meta_value_num' );
$query->set( 'meta_key', 'thim_real_student_enrolled' );
$query->set( 'order', 'DESC' );
break;
case 'price':
$query->set( 'orderby', 'price' );
$query->set( 'order', 'ASC' );
default:
$query->set( 'orderby', 'date' );
$query->set( 'order', 'DESC' );
}
}
任何帮助表示赞赏。