//do not show first two posts as they are featured and are already shown. //Could not exclude them from query without breaking pagination } else { $more = 0; get_template_part('content', get_post_format()); } } ?> <?php // kcsite_nice_pagination($the_query->max_num_pages); /* * for news page we need only 3 paged pages, older can be reached through archive */ $max = $the_query->max_num_pages > 3 ? 3 : $the_query->max_num_pages; kcsite_nice_pagination($max); ?> <div class="clearfix newsarchive-btn-wrap"> <a href="<?php echo $staticVars['industryNewsArchiveUrl']; ?> " class="btn-block fr"><?php pll_e('Industrijos naujienų archyvas'); ?> </a> </div> <?php wp_reset_query(); wp_reset_postdata(); ?>
/** * Main plugin function. Outputs film search and listing view */ function shortcodeFilmRegisterSearch($atts, $content = null) { wp_enqueue_style('jquery-ui', $this->pluginUrl . '/vendors/jquery-ui.custom/css/smoothness/jquery-ui.custom.min.css'); wp_enqueue_script('jquery-ui', $this->pluginUrl . '/vendors/jquery-ui.custom/js/jquery-ui.custom.min.js', array('jquery'), '1.0', true); wp_enqueue_script('jquery-ui-datepicker-lt', $this->pluginUrl . '/vendors/jquery-ui.custom/js/jquery.ui.datepicker-lt.js', array('jquery-ui'), '1.0', true); wp_enqueue_script('lkc-film-register-frontend', $this->pluginUrl . '/assets/js/frontend.js', array('jquery-ui'), '1.1', true); ob_start(); ?> <div class="film-register-search-form-wrap"> <hr class="single-hr"/> <h2 class="fancy-title"> <?php pll_e('Paieškos forma'); ?> </h2> <form method="get" action="<?php echo $_SERVER['REQUEST_URI']; ?> " class="film-register-search-form clearfix"> <input type="hidden" name="do" value="search"/> <table class="no-border"> <?php $shownFields = array(); foreach ($this->fields as $key => $val) { if ($val['searchInFrontEnd'] == true) { ?> <tr> <td class="first"><label> <?php $label = isset($val['labelFirst']) ? $val['labelFirst'] : $val['label']; echo $label; ?> </label></td> <td class="second"> <?php $options = array(); $options['name'] = $key; echo $this->sihf_output($options); ?> </td> </tr> <?php $shownFields[] = $key; } } // additional row - merging shower and first_record_producer as applier ("paraiskos teikejas"): if (isset($this->fields['applier'])) { $key = 'applier'; $val = $this->fields[$key]; $shownFields[] = $key; ?> <tr> <td class="first"><label> <?php $label = isset($val['labelFirst']) ? $val['labelFirst'] : $val['label']; echo $label; ?> </label></td> <td class="second"> <?php $options = array(); $options['name'] = $key; echo $this->sihf_output($options); ?> </td> </tr> <?php } // show dynamically added options. Doing it here, so they appear in the bottom, not among for all users visible fields $currentDynamicFields = array(); foreach ($this->fields as $key => $val) { if (!in_array($key, $shownFields) && ($val['searchHandleType'] != 'between_related_with_other_field' || $val['searchHandleType'] == 'between_related_with_other_field' && $val['searchRelatedFieldFirst'] == true)) { if ($val['searchInFrontEnd'] == false || current_user_can('administrator') || current_user_can('semi_admin')) { if (isset($_GET[$key]) && !empty($_GET[$key]) || isset($_GET[$key . '_from']) && !empty($_GET[$key . '_from']) || isset($_GET[$key . '_to']) && !empty($_GET[$key . '_to'])) { $currentDynamicFields[] = $key; ?> <tr> <td class="first"><label> <?php $label = isset($val['labelFirst']) ? $val['labelFirst'] : $val['label']; echo $label; ?> </label></td> <td class="second"> <?php $options = array(); $options['name'] = $key; echo $this->sihf_output($options); ?> <?php echo $this->getHtmlRemoveRowIcon(); ?> </td> </tr> <?php } } } } ?> <?php if (current_user_can('administrator') || current_user_can('semi_admin')) { ?> <tr id="dynamic-search-fields-add-wrap"> <td class="first">Pridėkite dar vieną kriterijų</td> <td class="second"> <select> <option value="0"><?php echo pll_e('Pasirinkite'); ?> </option> <?php foreach ($this->fields as $key => $val) { if ($val['searchInFrontEnd'] == false) { ?> <option value="<?php echo $key; ?> " data-name="<?php echo $key; ?> " <?php if (in_array($key, $currentDynamicFields)) { echo 'disabled="disabled"'; } ?> ><?php echo $val['label']; ?> </option> <?php } } ?> </select> <a href="#" class="btn-block"><?php echo pll_e('Pridėti'); ?> </a> </td> </tr> <?php } ?> </table> <input type="submit" class="" value="<?php pll_e('Ieškoti'); ?> " /> <br> <br> <?php // http://www.wpbeginner.com/wp-tutorials/how-to-create-advanced-search-form-in-wordpress-for-custom-post-types/ // http://scribu.net/wordpress/advanced-metadata-queries.html if (isset($_GET['do']) && $_GET['do'] == 'search') { $paged = get_query_var('paged') ? get_query_var('paged') : 1; $args = array('post_type' => $this->cptSlug, 'posts_per_page' => 20, 'paged' => $paged, 'offset' => ($paged - 1) * 20, 'numberposts' => -1); if (isset($_GET['show_amount'])) { $args['posts_per_page'] = $_GET['show_amount']; } if (isset($_GET['orderby']) && $_GET['orderby'] == 'title') { $args['orderby'] = 'title'; } else { if (isset($_GET['orderby']) && $_GET['orderby'] != 'title' && isset($this->fields[$_GET['orderby']])) { $key = $_GET['orderby']; if ($this->fields[$key]['metaType'] == 'meta') { $args['orderby'] = 'meta_value'; $args['meta_key'] = '_lkc_film_' . $_GET['orderby']; } else { if ($this->fields[$key]['metaType'] == 'taxonomy') { } } } else { // default ordering $args['orderby'] = 'meta_value'; $args['meta_key'] = '_lkc_film_identity_code'; } } if (isset($_GET['order']) && strtoupper($_GET['order'] == 'DESC')) { $args['order'] = 'DESC'; } else { $args['order'] = 'ASC'; } foreach ($this->fields as $key => $val) { if ($val['searchInFrontEnd'] == true || current_user_can('administrator') || current_user_can('semi_admin')) { if (isset($_GET[$key]) && !empty($_GET[$key]) || isset($_GET[$key . '_from']) && !empty($_GET[$key . 'from']) || isset($_GET[$key . '_to']) && !empty($_GET[$key . '_to'])) { if ($val['searchHandleType'] == 's') { $args['s'] = $_GET['title']; // handle additionaly added search row - applier // if any other such fields is going to be added, wpuld write separate method } elseif ($val['searchHandleType'] == 'metaQueryLike' && $key == 'applier') { $args['meta_query']['relation'] = 'OR'; $args['meta_query'][] = array('key' => '_lkc_film_shower', 'value' => $_GET[$key], 'compare' => 'LIKE'); $args['meta_query'][] = array('key' => '_lkc_film_first_record_producer', 'value' => $_GET[$key], 'compare' => 'LIKE'); } elseif ($val['searchHandleType'] == 'metaQueryLike') { $args['meta_query'][] = array('key' => '_lkc_film_' . $key, 'value' => $_GET[$key], 'compare' => 'LIKE'); } elseif ($val['searchHandleType'] == 'metaQueryEqual') { $args['meta_query'][] = array('key' => '_lkc_film_' . $key, 'value' => $_GET[$key]); } elseif ($val['searchHandleType'] == 'metaQueryInArray') { // multiple select $args['meta_query'][] = array('key' => '_lkc_film_' . $key, 'value' => $_GET[$key], 'compare' => 'LIKE'); } elseif ($val['searchHandleType'] == 'taxonomy') { $args[$val['taxonomySlug']] = $_GET[$key]; } elseif ($val['searchHandleType'] == 'between') { if (isset($_GET[$key . '_from']) && !empty($_GET[$key . '_from'])) { $args['meta_query'][] = array('key' => '_lkc_film_' . $key, 'value' => $_GET[$key . '_from'], 'compare' => '>='); } if (isset($_GET[$key . '_to']) && !empty($_GET[$key . '_to'])) { $args['meta_query'][] = array('key' => '_lkc_film_' . $key, 'value' => $_GET[$key . '_to'], 'compare' => '<='); } } elseif ($val['searchHandleType'] == 'between_related_with_other_field') { if ($val['searchRelatedFieldFirst'] == true) { $compare = '>='; } else { $compare = '<='; } $args['meta_query'][] = array('key' => '_lkc_film_' . $key, 'value' => $_GET[$key], 'compare' => $compare); } } } } // print_r($args);exit; $the_query = new WP_Query($args); // $args2 = $args; // $args2['posts_per_page'] = -1; // unset($args2['offset']); // unset($args2['paged']); // $the_query2 = new WP_Query( $args2 ); // print_r($the_query2);exit; // set ordering params for view display if (isset($_GET['order']) && strtoupper($_GET['order'] == 'DESC')) { $orderAlt = 'ASC'; $orderAltTitle = pll__('Rikiuoti didėjimo tvarka'); $orderIcon = 'desc'; } else { $orderAlt = 'DESC'; $orderAltTitle = pll__('Rikiuoti mažėjimo tvarka'); $orderIcon = 'asc'; } $listTableFields = $this->data->getListTableFields(); ?> <hr class="single-hr"/> <div class="film-register-search-results-header clearfix"> <h2 class="fancy-title"> <?php pll_e('Paieškos rezultatai'); ?> <?php /*if($the_query2) { ?> <span class="film-count">(<?php echo $the_query2->post_count;?>)</span> <?php }*/ ?> </h2> <?php if ($the_query && $the_query->post_count > 0) { ?> <div class="print-wrap"> <a href="#" class="js-print-btn" data-div="film-list-print-wrap"> <i class="icon-print"></i></a> </div> <?php } ?> <?php if ($the_query && $the_query->post_count > 1) { ?> <div class="show-amount-wrap"> <span><?php pll_e('rodyti'); ?> </span> <select name="show_amount"> <?php $amounts = array(20 => 20, 50 => 50, 100 => 100, -1 => pll__('visus')); foreach ($amounts as $key => $val) { ?> <option value="<?php echo $key; ?> "<?php if ($_GET['show_amount'] == $key || !isset($_GET['show_amount']) && $key == 20) { echo 'selected="selected"'; } ?> ><?php echo $val; ?> </option> <?php } ?> </select> </div> <div class="orderby-wrap"> <span><?php pll_e('rikiuoti pagal'); ?> </span> <select name="orderby" class="orderby"> <?php foreach ($listTableFields as $key => $val) { if ($val['metaType'] != 'taxonomy') { ?> <option value="<?php echo $key; ?> "<?php if ($_GET['orderby'] == $key || !isset($_GET['orderby']) && $key == 'identity_code') { echo 'selected="selected"'; } ?> ><?php echo strtolower($val['label']); ?> </option> <?php } } ?> </select> <a href="<?php echo add_query_arg(array('order' => $orderAlt), $_SERVER['REQUEST_URI']); ?> " class="order-direction" title="<?php echo $orderAltTitle; ?> "> <i class="icon-order-<?php echo $orderIcon; ?> "></i> </a> </div> <?php } ?> </div><!-- .film-register-search-results-header --> <?php if ($the_query === false) { ?> <p><?php pll_e('Prašome įvesti bent 1 paieškos kriterijų'); ?> </p> <?php } elseif ($the_query->post_count < 1) { ?> <p><?php pll_e('Pagal pasirinktus paieškos kriterijus filmų nerasta'); ?> </p> <?php } else { ?> <div id="film-list-print-wrap"> <table class="film-register-list-table film-print-table"> <tr> <?php foreach ($listTableFields as $key => $val) { $orderLink = add_query_arg(array('orderby' => $key), $_SERVER['REQUEST_URI']); $orderIcon = ''; if (isset($_GET['orderby']) && $_GET['orderby'] == $key || !isset($_GET['orderby']) && $key == 'identity_code') { if (isset($_GET['order']) && strtoupper($_GET['order'] == 'DESC')) { $orderLink = add_query_arg(array('order' => 'ASC'), $orderLink); $orderIcon = 'desc'; } else { $orderLink = add_query_arg(array('order' => 'DESC'), $orderLink); $orderIcon = 'asc'; } } ?> <th> <?php if ($val['metaType'] != 'taxonomy') { ?> <a href="<?php echo $orderLink; ?> "> <?php } ?> <?php echo $val['label']; ?> <?php if ($orderIcon != '') { ?> <i class="icon-order-<?php echo $orderIcon; ?> "></i> <?php } ?> <?php if ($val['metaType'] != 'taxonomy') { ?> </a> <?php } ?> </th> <?php } ?> </tr> <?php while ($the_query->have_posts()) { $the_query->the_post(); ?> <tr> <?php foreach ($listTableFields as $key => $val) { ?> <td> <?php if ($key == 'title') { ?> <a href="<?php the_permalink(); ?> "> <?php } ?> <?php echo $this->data->getFieldData(get_the_ID(), $key); ?> <?php if ($key == 'title') { ?> </a> <?php } ?> </td> <?php } ?> </tr> <?php } ?> </table> </div> <?php kcsite_nice_pagination($the_query->max_num_pages); wp_reset_query(); wp_reset_postdata(); } } ?> </form> </div> <!-- film-register-search-form-wrap --> <script type="text/javascript"> jQuery(document).ready(function(){ jQuery('.js-print-btn').click(function(){ handlePrintBtnClick(jQuery(this), '<?php echo $this->pluginUrl; ?> /assets/css/print.css'); }); }); </script> <?php $output = ob_get_clean(); return do_shortcode($output); }
<hr class="double-hr entry-header-hr"/> <?php global $post; global $more; $paged = get_query_var('paged') ? get_query_var('paged') : 1; $args = array('post_type' => 'interesting-fact', 'orderby' => 'date', 'order' => 'DESC', 'paged' => $paged, 'posts_per_page' => get_option('posts_per_page'), 'post_status' => 'publish'); $the_query = new WP_Query($args); ?> <?php while ($the_query->have_posts()) { $the_query->the_post(); $more = 0; get_template_part('content', get_post_format()); } ?> <?php kcsite_nice_pagination($the_query->max_num_pages); wp_reset_query(); wp_reset_postdata(); ?> </div><!-- .page-content --> </div> <?php get_footer();
<hr class="double-hr entry-header-hr"/> <?php if (have_posts()) { ?> <?php global $k; $k = 0; while (have_posts()) { $k++; the_post(); get_template_part('content', get_post_format()); } unset($k); ?> <?php kcsite_nice_pagination('', 2); ?> <?php } ?> </div><!-- .page-content --> </div> <?php get_footer();
<?php while (have_posts()) { the_post(); ?> <?php get_template_part('content', get_post_format()); ?> <?php } ?> <?php kcsite_nice_pagination(); ?> <?php } else { ?> <article id="post-0" class="post no-results not-found"> <div class="entry-content"> <p><?php _e('Sorry, but nothing matched your search criteria. Please try again with some different keywords.', 'kcsite'); ?> </p> <?php get_search_form(); ?>