Custom Post by Custom Texo filter
Thu Jul 06 2023 12:09:36 GMT+0000 (Coordinated Universal Time)
Saved by @gshailesh27
<form> <select class="form-select w-100" aria-label="Default select example" name="location"> <option selected disabled>Location</option> <?php $coursetypes = get_terms("coursecity"); foreach ($coursetypes as $coursetype): ?> <option value="<?php echo esc_html( $coursetype->slug ); ?>"><?php echo esc_html($coursetype->name); ?></option> <?php endforeach; ?> </select> <input type="submit" value="Search"/> </form> <?php if ( !isset($_GET["country"]) && !isset($_GET["location"]) && !isset($_GET["category"]) && !isset($_GET["language"]) && !isset($_GET["wfh"]) && !isset($_GET["title"]) ) { $wpnew = [ "post_type" => "courses", "post_status" => "publish", "orderby" => "ID", "order" => "ASC", ]; //'post_name__in' => ['post-slug'] } else { $wpnew = [ "post_type" => "courses", "posts_per_page" => -1, "post_status" => "publish", "orderby" => "ID", "order" => "ASC", "s" => $_GET["title"], "coursecategory" => $_GET["category"], "coursetype" => $_GET["type"], "coursecity" => $_GET["location"], ]; } $newsquery = new wp_Query($wpnew); if ($newsquery->have_posts()) { while ($newsquery->have_posts()) { $newsquery->the_post(); //$terms = get_the_terms( $post->ID, 'coursecity' ); ?> <div class="col-md-6"> <div class="course-card"> <div class="course-thumb"> <img src="<?php echo get_the_post_thumbnail_url(); ?>" class="h-100" width="100%"> </div> <div class="course-details"> <p class="course-title mb-2"><?php the_title(); ?></p> <div class="course-calenderbox mb-2"> <div class="course-duration"><i class="fa fa-calendar-o" aria-hidden="true"></i> <?php the_cfc_field( "course-details", "course-duration-in-months" ); ?> Months</div> <div class="course-location"><i class="fa fa-map-marker" aria-hidden="true"></i> <?php foreach ( $terms as $term ) { echo $term->name; } ?></div> </div> <div class="course-exceprt"><?php the_cfc_field( "course-details", "course-sort-description" ); ?></div> <a href="<?php the_permalink(); ?>" class="course-btn mt-3">View Details</a> </div> </div> </div> <?php } } else { echo "<h5 class='mb-5 mt-3 text-center'>Course Not Found!!!</h5>"; } wp_reset_postdata(); ?>
Comments