Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_shortcode( 'themeum_hotel_listing', function($atts, $content = null) {
- extract(shortcode_atts(array(
- 'category_package' => 'themeumall',
- 'number' => '6',
- 'column' => '4',
- 'layoutstyle' => 'style1',
- 'order_by' => 'date',
- 'paginationen' => 'no',
- 'order' => 'DESC',
- 'class' => '',
- ), $atts));
- global $post;
- $posts = 0;
- $temp_post = $post;
- $output = $args = '';
- $pagenum = max( 1, get_query_var('paged') );
- // The Query
- if( $category_package == 'themeumall' ){
- $args = array(
- 'post_type' => 'hotel',
- 'order' => esc_attr($order),
- 'orderby' => esc_attr($order_by),
- 'posts_per_page' => esc_attr($number),
- 'paged' => $pagenum
- );
- }else{
- $args = array(
- 'post_type' => 'hotel',
- 'order' => 'DESC',
- 'tax_query' => array(
- array(
- 'taxonomy' => 'hotel-category',
- 'field' => 'slug',
- 'terms' => esc_attr($category_package),
- ),
- ),
- 'order' => esc_attr($order),
- 'orderby' => esc_attr($order_by),
- 'posts_per_page' => esc_attr($number),
- 'paged' => $pagenum
- );
- }
- $posts = get_posts( $args );
- if(count($posts)>0){
- // The Loop
- $output .= '<div class="add-popular-tour-package">';
- $output .= '<div class="row">';
- foreach ($posts as $key=>$mpost): setup_postdata($mpost);
- $hotelduration = get_post_meta($mpost->ID,'themeum_hotelduration',true);
- $roominfo = get_post_meta($mpost->ID,'themeum_room_info',true);
- $output .= '<div class="col-sm-6 col-md-'.esc_attr($column).'">';
- if ( $layoutstyle == 'style2' ) {
- $output .= '<div class="package-list-wrap package-list-wrap-v2">';
- $output .= '<div class="package-img-wrap">';
- $output .= get_the_post_thumbnail($mpost->ID,'travelkit-medium', array('class' => 'img-responsive'));
- $hotel_book_btn = get_theme_mod('hotel_booknow_btn');
- if (isset($hotel_book_btn) && $hotel_book_btn != '') {
- $output .= '<a class="package-list-button" href="'.get_the_permalink($mpost->ID).'">'.$hotel_book_btn.'</a>';
- }else {
- $output .= '<a class="package-list-button" href="'.get_the_permalink($mpost->ID).'">'.__('View Details','themeum-core').'</a>';
- }
- $output .= '</div>'; //package-img-wrap
- $output .= '<div class="package-list-content">';
- $hotel_price_min = '';
- if (!empty($roominfo)) {
- $temp_prices = array();
- foreach ($roominfo as $hotel_price) {
- if (isset($hotel_price['themeum_roomprice'])) {
- $temp_prices[] = $hotel_price['themeum_roomprice'];
- }
- }
- if (!empty($temp_prices)) {
- if (!get_theme_mod( 'currency_right' )) {
- $hotel_price_min = get_theme_mod( 'other_currency', '$' ).min($temp_prices);
- } else {
- $hotel_price_min = min($temp_prices).get_theme_mod( 'other_currency', '$' );
- }
- }
- }
- $output .= '<h3 class="package-list-title"><a href="'.get_the_permalink($mpost->ID).'">'.get_the_title($mpost->ID).'</a></h3>';
- if ($hotelduration != '' || $hotel_price_min != '' ) {
- $output .= '<p class="package-list-duration">' .__('Start from','themeum-core').' '.$hotel_price_min. '/'. $hotelduration .'</p>';
- }
- $output .= '</div>';//package-list-content
- $output .= '</div>';//package-list-wrap
- } elseif ( $layoutstyle == 'style3' ) {
- $output .= '<div class="package-list-wrap package-list-wrap-v3">';
- $output .= '<div class="package-img-wrap">';
- $output .= get_the_post_thumbnail($mpost->ID,'travelkit-medium', array('class' => 'img-responsive'));
- $hotel_book_btn = get_theme_mod('hotel_booknow_btn');
- if (isset($hotel_book_btn) && $hotel_book_btn != '') {
- $output .= '<a class="package-list-button" href="'.get_the_permalink($mpost->ID).'">'.$hotel_book_btn.'</a>';
- }else {
- $output .= '<a class="package-list-button" href="'.get_the_permalink($mpost->ID).'">'.__('View Details','themeum-core').'</a>';
- }
- $output .= '</div>'; //package-img-wrap
- $output .= '<div class="package-list-content">';
- $hotel_price_min = '';
- if (!empty($roominfo)) {
- $temp_prices = array();
- foreach ($roominfo as $hotel_price) {
- if (isset($hotel_price['themeum_roomprice'])) {
- $temp_prices[] = $hotel_price['themeum_roomprice'];
- }
- }
- if (!empty($temp_prices)) {
- if (!get_theme_mod( 'currency_right' )) {
- $hotel_price_min = get_theme_mod( 'other_currency', '$' ).min($temp_prices);
- } else {
- $hotel_price_min = min($temp_prices).get_theme_mod( 'other_currency', '$' );
- }
- }
- }
- $output .= '<h3 class="package-list-title"><a href="'.get_the_permalink($mpost->ID).'">'.get_the_title($mpost->ID).'</a></h3>';
- if ($hotelduration != '' || $hotel_price_min != '' ) {
- $output .= '<p class="package-list-duration">' .__('Start from','themeum-core').' '.$hotel_price_min. '/'. $hotelduration .'</p>';
- }
- $output .= '</div>';//package-list-content
- $output .= '</div>';//package-list-wrap
- } else{
- $output .= '<div class="package-list-wrap">';
- $output .= get_the_post_thumbnail($mpost->ID,'travelkit-medium', array('class' => 'img-responsive'));
- $output .= '<div class="package-list-content">';
- $hotel_price_min = '';
- if (!empty($roominfo)) {
- $temp_prices = array();
- foreach ($roominfo as $hotel_price) {
- if (isset($hotel_price['themeum_roomprice'])) {
- $temp_prices[] = $hotel_price['themeum_roomprice'];
- }
- }
- if (!empty($temp_prices)) {
- if (!get_theme_mod( 'currency_right' )) {
- $hotel_price_min = get_theme_mod( 'other_currency', '$' ).min($temp_prices);
- } else {
- $hotel_price_min = min($temp_prices).get_theme_mod( 'other_currency', '$' );
- }
- }
- }
- if ($hotelduration != '' || $hotel_price_min != '' ) {
- $output .= '<p class="package-list-duration">' .__('Start from','themeum-core').' '.$hotel_price_min. '/'. $hotelduration .'</p>';
- }
- $output .= '<h3 class="package-list-title"><a href="'.get_the_permalink($mpost->ID).'">'.get_the_title($mpost->ID).'</a></h3>';
- $hotel_book_btn = get_theme_mod('hotel_booknow_btn');
- if (isset($hotel_book_btn) && $hotel_book_btn != '') {
- $output .= '<a class="package-list-button" href="'.get_the_permalink($mpost->ID).'">'.$hotel_book_btn.'</a>';
- }else {
- $output .= '<a class="package-list-button" href="'.get_the_permalink($mpost->ID).'">'.__('View Details','themeum-core').'</a>';
- }
- $output .= '</div>';//package-list-content
- $output .= '</div>';//package-list-wrap
- }
- $output .= '</div>';//col-sm-6
- endforeach;
- $output .= '</div>'; //row
- wp_reset_postdata();
- $output .= '</div>';//add-popular-tour-package
- //pagination
- if($paginationen == 'yes') {
- $args['posts_per_page'] = -1;
- $total_post = get_posts( $args );
- $var = $number;
- if( $var == "" || $var == 0 ){
- $total_post = 1;
- }else{
- $total_post = ceil( count($total_post)/(int)$var );
- }
- $output .= '<div class="themeum-pagination">';
- $big = 999999999; // need an unlikely integer
- $output .= paginate_links( array(
- 'type' => 'list',
- 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) )),
- 'format' => '?paged=%#%',
- 'current' => $pagenum,
- 'total' => $total_post
- ) );
- $output .= '</div>'; //pagination-in
- }
- }
- $post = $temp_post;
- return $output;
- });
- //Visual Composer
- if (class_exists('WPBakeryVisualComposerAbstract')) {
- vc_map(array(
- "name" => esc_html__("Hotel Listing", 'themeum-core'),
- "base" => "themeum_hotel_listing",
- 'icon' => 'icon-thm-hotel',
- "class" => "",
- "description" => esc_html__("Widget Title Heading", 'themeum-core'),
- "category" => esc_html__('Travelkit', 'themeum-core'),
- "params" => array(
- array(
- "type" => "dropdown",
- "heading" => esc_html__("Layout style", "themeum-core"),
- "param_name" => "layoutstyle",
- "value" => array('Select'=>'','Style 1'=>'style1','Style 2'=>'style2','Style 3'=>'style3'),
- ),
- array(
- "type" => "dropdown",
- "heading" => esc_html__("Category Filter", 'themeum-core'),
- "param_name" => "hotel-category",
- "value" => themeum_cat_list('hotel-category'),
- ),
- array(
- "type" => "textfield",
- "heading" => esc_html__("Number of items", 'themeum-core'),
- "param_name" => "number",
- "value" => "6",
- ),
- array(
- "type" => "dropdown",
- "heading" => esc_html__("Number Of Column", "themeum-core"),
- "param_name" => "column",
- "value" => array('Select'=>'','column 2'=>'6','column 3'=>'4','column 4'=>'3'),
- ),
- array(
- "type" => "dropdown",
- "heading" => esc_html__("Order", 'themeum-core'),
- "param_name" => "order",
- "value" => array('None'=>'','DESC'=>'DESC','ASC'=>'ASC'),
- ),
- array(
- "type" => "dropdown",
- "heading" => esc_html__("OderBy", 'themeum-core'),
- "param_name" => "order_by",
- "value" => array('None'=>'','Date'=>'date','Title'=>'title','Modified'=>'modified','Author'=>'author','Random'=>'rand'),
- ),
- array(
- "type" => "dropdown",
- "heading" => esc_html__("Pagination", 'themeum-core'),
- "param_name" => "paginationen",
- "value" => array('None'=>'','YES'=>'yes','NO'=>'no'),
- ),
- array(
- "type" => "textfield",
- "heading" => esc_html__("Custom Class", 'themeum-core'),
- "param_name" => "class",
- "value" => "",
- ),
- )
- ));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement