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');
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_edit_form_fields', 'edit_course_promo', 10, 2 );
add_action( 'created_vq_course_promo', 'save_course_promo', 10, 2 );
......
......@@ -28,6 +28,24 @@ $courses = new WP_Query(array(
'orderby'=>'title',
'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()):
the_post();
?>
......@@ -147,20 +165,29 @@ while (have_posts()):
<div class="lms-courses-select">
<select class="form-control" data-placeholder="Select a course...">
<option value=""></option>
<?php foreach($categories as $term): ?>
<?php if($term->parent != 0): ?>
<optgroup label="<?php echo $term->name; ?>">
<?php
$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)
));
?>
<option value="<?php the_ID(); ?>"><?php the_title(); ?></option>
<?php
}
$args = array(
'post_type' => 'vq_course',
'posts_per_page' => '-1',
'tax_query' => array(
array(
'taxonomy' => 'vq_course_taxonomy',
'field' => 'slug',
'terms' => $term->name
),
),
);
$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>
</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