Commit 10d74bc3 by Muhammad Usman

courses by sub category

parent e3298eec
Pipeline #373 passed with stage
in 0 seconds
...@@ -34,21 +34,6 @@ add_shortcode('vq_course_banner', 'vq_render_course_banner'); ...@@ -34,21 +34,6 @@ add_shortcode('vq_course_banner', 'vq_render_course_banner');
add_shortcode('vq_lms_inquiry_form', 'vq_render_inquiry_form'); add_shortcode('vq_lms_inquiry_form', 'vq_render_inquiry_form');
add_filter('the_title','change_title');
function change_title($data) {
global $post;
$title = get_post_meta($post->ID, 'lms_title', true);
if ($title != null) {
$data = $title;
}
return $data;
}
add_action( 'vq_course_promo_add_form_fields', 'add_course_promo', 10, 2 ); add_action( 'vq_course_promo_add_form_fields', 'add_course_promo', 10, 2 );
add_action( 'vq_course_promo_edit_form_fields', 'edit_course_promo', 10, 2 ); add_action( 'vq_course_promo_edit_form_fields', 'edit_course_promo', 10, 2 );
add_action( 'created_vq_course_promo', 'save_course_promo', 10, 2 ); add_action( 'created_vq_course_promo', 'save_course_promo', 10, 2 );
......
...@@ -28,6 +28,24 @@ $courses = new WP_Query(array( ...@@ -28,6 +28,24 @@ $courses = new WP_Query(array(
'orderby'=>'title', 'orderby'=>'title',
'order'=>'ASC' 'order'=>'ASC'
)); ));
$coursesArr = [];
while($courses->have_posts()) {
$courses->the_post();
array_push($coursesArr,array(
"id" => get_the_ID(),
"name" => get_the_title(),
"cost" => get_post_meta(get_the_ID(), 'course_fee', true)
));
}
$categories = get_terms( array(
'taxonomy' => 'vq_course_taxonomy',
'hide_empty' => false,
));
while (have_posts()): while (have_posts()):
the_post(); the_post();
?> ?>
...@@ -147,20 +165,29 @@ while (have_posts()): ...@@ -147,20 +165,29 @@ while (have_posts()):
<div class="lms-courses-select"> <div class="lms-courses-select">
<select class="form-control" data-placeholder="Select a course..."> <select class="form-control" data-placeholder="Select a course...">
<option value=""></option> <option value=""></option>
<?php foreach($categories as $term): ?>
<?php if($term->parent != 0): ?>
<optgroup label="<?php echo $term->name; ?>">
<?php <?php
$coursesArr = []; $args = array(
while($courses->have_posts()) { 'post_type' => 'vq_course',
$courses->the_post(); 'posts_per_page' => '-1',
array_push($coursesArr,array( 'tax_query' => array(
"id" => get_the_ID(), array(
"name" => get_the_title(), 'taxonomy' => 'vq_course_taxonomy',
"cost" => get_post_meta(get_the_ID(), 'course_fee', true) 'field' => 'slug',
)); 'terms' => $term->name
?> ),
<option value="<?php the_ID(); ?>"><?php the_title(); ?></option> ),
<?php );
} $list = new WP_Query($args);
foreach($list->posts as $crs):
echo "<option value='" . $crs->ID . "'>". $crs->post_title ."</option>";
endforeach;
?> ?>
</optgroup>
<?php endif;?>
<?php endforeach; ?>
</select> </select>
</div> </div>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment