Advertisement
Guest User

Untitled

a guest
Jan 7th, 2016
447
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.38 KB | None | 0 0
  1. <?php get_header(); ?>
  2. <?php
  3. $cats = get_categories();
  4. $category = '';
  5. $year = '';
  6. $monthnum = '';
  7. $filter = '';
  8. $sortby = '';
  9. if (isset($_GET['category'])) {
  10. $category = htmlspecialchars($_GET['category'], ENT_QUOTES, 'UTF-8');
  11. }
  12. if (isset($_GET['year'])) {
  13. $year = (int)$_GET['year'];
  14. }
  15. if (isset($_GET['month'])) {
  16. $monthnum = (int)$_GET['month'];
  17. }
  18.  
  19. if (isset($_GET['format'])) {
  20. $filter = htmlspecialchars($_GET['format'], ENT_QUOTES, 'UTF-8');
  21. }
  22.  
  23. if (isset($_GET['sortby'])) {
  24. $sortby = htmlspecialchars($_GET['sortby'], ENT_QUOTES, 'UTF-8');
  25. }
  26. $s = htmlspecialchars($s, ENT_QUOTES, 'UTF-8');
  27.  
  28. //$months = range(1,12);
  29. $months = array (
  30. '1' => __('January', 'framework'),
  31. '2' => __('February', 'framework'),
  32. '3' => __('March', 'framework'),
  33. '4' => __('April', 'framework'),
  34. '5' => __('May', 'framework'),
  35. '6' => __('June', 'framework'),
  36. '7' => __('July', 'framework'),
  37. '8' => __('August', 'framework'),
  38. '9' => __('September', 'framework'),
  39. '10' => __('October', 'framework'),
  40. '11' => __('November', 'framework'),
  41. '12' => __('December', 'framework')
  42. );
  43. $formats = get_theme_support( 'post-formats' );
  44. $filterq = '';
  45. if ($filter != '') {
  46. $filterq = array(
  47. array(
  48. 'taxonomy' => 'post_format',
  49. 'field' => 'slug',
  50. 'terms' => array('post-format-'.$filter),
  51. )
  52. );
  53. }
  54. $post_meta_hp = mom_option('post_meta_hp');
  55. if($post_meta_hp == 1) {
  56. $post_head = mom_option('post_head');
  57. $post_head_author = mom_option('post_head_author');
  58. $post_head_date = mom_option('post_head_date');
  59. $post_head_cat = mom_option('post_head_cat');
  60. $post_head_commetns= mom_option('post_head_commetns');
  61. $post_head_views = mom_option('post_head_views');
  62. } else {
  63. $post_head = 1;
  64. $post_head_author = 1;
  65. $post_head_date = 1;
  66. $post_head_cat = 1;
  67. $post_head_commetns= 1;
  68. $post_head_views = 1;
  69. }
  70. ?>
  71.  
  72. <form role="search" method="get" id="advanced-search" action="<?php echo home_url('/'); ?>">
  73. <div class="main-container search-page"><!--container-->
  74. <?php if(mom_option('breadcrumb') != 0) { ?>
  75. <?php if(mom_option('search_bread') != false) { ?>
  76. <div class="entry-crumbs" xmlns:v="http://rdf.data-vocabulary.org/#">
  77. <div class="crumb-icon"><i class="momizat-icon-search"></i></div>
  78. <?php mom_breadcrumb(); ?>
  79. </div>
  80. <?php } ?>
  81. <?php } ?>
  82.  
  83. <?php if(mom_option('adv_search') != false) { ?>
  84. <section class="section advanced-search clearfix">
  85. <div class="adv-search-form">
  86. <label for="adv-s"><?php _e('keywords:', 'framework'); ?></label>
  87. <input type="text" id="adv-s" class="adv-s" placeholder="<?php _e('Enter keywords', 'framework'); ?>" value="<?php echo $s; ?>" name="s" data-nokeyword="<?php _e('Keyword is required.', 'framework'); ?>">
  88. <span class="adv-s-cat">
  89. <label for="adv-cat"><?php _e('Category:', 'framework'); ?></label>
  90. <div class="select-wrap">
  91. <select id="adv-cat" name="category">
  92. <?php
  93. echo '<option value="">'.__('All', 'framework').'</option>';
  94. foreach ( $cats as $cat ) {
  95. echo '<option value="'.$cat->term_id.'"'.selected( $category, $cat->term_id ).'>' . $cat->name . '</option>';
  96. }
  97. ?>
  98. </select>
  99. <div class="sort-arrow"></div>
  100. </div>
  101. </span>
  102. <span class="adv-s-month">
  103. <label for="adv-year"><?php _e('Date:', 'framework'); ?></label>
  104. <div class="select-wrap">
  105. <select id="adv-year" name="year">
  106. <?php
  107. echo '<option value="">...</option>';
  108. echo mom_get_years('year');
  109. ?>
  110. </select>
  111. <div class="sort-arrow"></div>
  112. </div>
  113. <div class="select-wrap">
  114. <select id="adv-mon" name="month">
  115. <?php
  116. echo '<option value="">...</option>';
  117. foreach ($months as $val => $name) { ?>
  118. <option value="<?php echo $val; ?>" <?php selected( $monthnum, $val ); ?>><?php echo $name; ?></option>
  119. <?php } ?>
  120. </select>
  121. <div class="sort-arrow"></div>
  122. </div>
  123. </span>
  124. <span class="adv-s-format">
  125. <label for="adv-format"><?php _e('Filter by:', 'framework'); ?></label>
  126. <div class="select-wrap">
  127. <select id="adv-format" name="format">
  128. <?php
  129. echo '<option value="">'.__('All', 'framework').'</option>';
  130. foreach ($formats[0] as $format) { ?>
  131. <option value="<?php echo $format; ?>" <?php selected( $filter, $format ); ?>><?php echo $format; ?></option>
  132. <?php } ?>
  133. </select>
  134. <div class="sort-arrow"></div>
  135. </div>
  136. </span>
  137. <input type="hidden" name="go">
  138. <input type="submit" class="submit" value="<?php _e('Search', 'framework'); ?>">
  139. </div>
  140. </section>
  141. <?php } ?>
  142. <div class="full-main-content" role="main"><!--Full width Main Content-->
  143.  
  144. <div class="site-content page-wrap nb1">
  145.  
  146. <header class="block-title">
  147. <h2><?php printf( __( 'Search Results for: %s', 'framework' ), get_search_query() ); ?></h2>
  148.  
  149. <?php if(mom_option('search_sort') != false) { ?>
  150. <div class="media-sort-form">
  151. <span class="media-sort-title"><?php _e('Sort by:', 'framework'); ?></span>
  152. <div class="media-sort-wrap">
  153. <select id="media-sort" name="sortby">
  154. <option value="DESC" <?php selected( $sortby, 'DESC' ); ?>><?php _e('Descending', 'framework'); ?></option>
  155. <option value="ASC" <?php selected( $sortby, 'ASC' ); ?>><?php _e('Ascending', 'framework'); ?></option>
  156. </select>
  157. <div class="sort-arrow"></div>
  158. </div>
  159. </div>
  160. <?php } ?>
  161. </header>
  162. <?php
  163. $posts_pre_page = mom_option('search_count');
  164. global $wp_query;
  165. if ( get_query_var('paged') ) { $paged = get_query_var('paged'); }
  166. elseif ( get_query_var('page') ) { $paged = get_query_var('page'); }
  167. else { $paged = 1; }
  168. $args = array (
  169. 's' => $s,
  170. 'category__in' => $category,
  171. 'year' => $year,
  172. 'monthnum' => $monthnum,
  173. 'paged' => $paged,
  174. 'order' => $sortby,
  175. 'tax_query' => $filterq,
  176. 'post_status' => 'publish'
  177. );
  178.  
  179.  
  180. //$query = new WP_Query($args) ;
  181. if ( $query->have_posts() ) :
  182. echo '<ul>';
  183. while ( $query->have_posts() ) : $query->the_post();
  184. if(mom_option('search_page_ex') == true) {
  185. if (is_type_page()) {
  186. continue;
  187. }
  188. }
  189. ?>
  190. <li <?php post_class(); ?> itemscope="" itemtype="http://schema.org/Article">
  191. <?php if (mom_post_image() != false) { ?>
  192. <figure class="post-thumbnail"><a href="<?php the_permalink(); ?>">
  193. <?php mom_post_image_full('search-grid'); ?>
  194. <span class="post-format-icon"></span>
  195. </a></figure>
  196. <?php } ?>
  197. <?php if( mom_post_image() != false ) {
  198. $mom_class = ' class="fix-right-content"';
  199. } else {
  200. $mom_class = '';
  201. }
  202. ?>
  203. <div<?php echo $mom_class; ?>>
  204. <h2 itemprop="name"><a itemprop="url" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
  205. <div class="entry-content">
  206. <p>
  207. <?php global $post;
  208. $excerpt = $post->post_excerpt;
  209. if($excerpt==''){
  210. $excerpt = get_the_content('');
  211. }
  212. echo wp_html_excerpt(strip_shortcodes($excerpt), 115);
  213. ?> ...
  214. </p>
  215. </div>
  216. <?php if($post_head != 0) { ?>
  217. <div class="entry-meta">
  218. <?php if($post_head_date != 0) { ?>
  219. <time class="entry-date" datetime="<?php the_time('c'); ?>" itemprop="dateCreated"><i class="momizat-icon-calendar"></i><?php echo mom_date_format(); ?></time>
  220. <?php } ?>
  221. <?php if($post_head_commetns != 0) { ?>
  222. <div class="comments-link">
  223. <i class="momizat-icon-bubbles4"></i><a href="<?php comments_link(); ?>"><?php comments_number(__( '(0) Comments', 'framework' ), __( '(1) Comment', 'framework' ),__( '(%) Comments', 'framework' )); ?></a>
  224. </div>
  225. <?php } ?>
  226. </div>
  227. <?php } ?>
  228. </div>
  229. </li>
  230. <?php endwhile;
  231. echo '</ul>';
  232. mom_pagination($query->max_num_pages);
  233. else: ?>
  234. <p><?php _e('Sorry, no posts matched your criteria.', 'framework'); ?></p>
  235. <?php endif; ?>
  236. <?php wp_reset_postdata(); ?>
  237. </div>
  238.  
  239. </div><!--Full width Main Content-->
  240. </div><!--container-->
  241. </form>
  242.  
  243. </div><!--wrap-->
  244. <?php get_footer();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement