search.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. <?php
  2. if ( !defined('ABSPATH') ){ die(); }
  3. global $avia_config, $more;
  4. /*
  5. * get_header is a basic wordpress function, used to retrieve the header.php file in your theme directory.
  6. */
  7. get_header();
  8. $showheader = true;
  9. if(avia_get_option('frontpage') && $blogpage_id = avia_get_option('blogpage'))
  10. {
  11. if(get_post_meta($blogpage_id, 'header', true) == 'no') $showheader = false;
  12. }
  13. if($showheader)
  14. {
  15. echo avia_title(array('title' => avia_which_archive()));
  16. }
  17. do_action( 'ava_after_main_title' );
  18. ?>
  19. <div class='container_wrap container_wrap_first main_color <?php avia_layout_class( 'main' ); ?>'>
  20. <div class='container template-blog '>
  21. <main class='content av-content-full alpha units' <?php avia_markup_helper(array('context' => 'content','post_type'=>'post'));?>>
  22. <?php
  23. $tds = term_description();
  24. if($tds)
  25. {
  26. echo "<div class='category-term-description'>{$tds}</div>";
  27. }
  28. ?>
  29. <?php
  30. $avia_config['blog_style'] = apply_filters('avf_blog_style', avia_get_option('blog_style','multi-big'), 'archive');
  31. if($avia_config['blog_style'] == 'blog-grid')
  32. {
  33. global $posts;
  34. $post_ids = array();
  35. foreach($posts as $post) $post_ids[] = $post->ID;
  36. if(!empty($post_ids))
  37. {
  38. $atts = array(
  39. 'type' => 'grid',
  40. 'items' => get_option('posts_per_page'),
  41. 'columns' => 3,
  42. 'preview_mode' => 'custom',
  43. 'image_size' => 'full',
  44. 'class' => 'avia-builder-el-no-sibling',
  45. 'paginate' => 'yes',
  46. 'use_main_query_pagination' => 'yes',
  47. 'custom_query' => array( 'post__in'=>$post_ids, 'post_type'=>get_post_types() )
  48. );
  49. $blog = new avia_post_slider($atts);
  50. $blog->query_entries();
  51. echo "<div class='entry-content-wrapper'>".$blog->html()."</div>";
  52. }
  53. else
  54. {
  55. get_template_part( 'includes/loop', 'index' );
  56. }
  57. }
  58. else
  59. {
  60. /* Run the loop to output the posts.
  61. * If you want to overload this in a child theme then include a file
  62. * called loop-index.php and that will be used instead.
  63. */
  64. $more = 0;
  65. //get_template_part( 'includes/loop', 'index' );
  66. global $post_loop_count;
  67. if(empty($post_loop_count)) $post_loop_count = 1;
  68. $blog_style = !empty($avia_config['blog_style']) ? $avia_config['blog_style'] : avia_get_option('blog_style','multi-big');
  69. if(is_single()) $blog_style = avia_get_option('single_post_style','single-big');
  70. $blog_global_style = avia_get_option('blog_global_style',''); //alt: elegant-blog
  71. $initial_id = avia_get_the_ID();
  72. // check if we got posts to display:
  73. if (have_posts()) :
  74. while (have_posts()) : the_post();
  75. /*
  76. * get the current post id, the current post class and current post format
  77. */
  78. $url = "";
  79. $current_post = array();
  80. $current_post['post_loop_count']= $post_loop_count;
  81. $current_post['the_id'] = get_the_ID();
  82. $current_post['parity'] = $post_loop_count % 2 ? 'odd' : 'even';
  83. $current_post['last'] = count($wp_query->posts) == $post_loop_count ? " post-entry-last " : "";
  84. $current_post['post_type'] = get_post_type($current_post['the_id']);
  85. $current_post['post_class'] = "post-entry-".$current_post['the_id']." post-loop-".$post_loop_count." post-parity-".$current_post['parity'].$current_post['last']." ".$blog_style;
  86. $current_post['post_class'] .= ($current_post['post_type'] == "post") ? '' : ' post';
  87. $current_post['post_format'] = get_post_format() ? get_post_format() : 'standard';
  88. $current_post['post_layout'] = avia_layout_class('main', false);
  89. $blog_content = !empty($avia_config['blog_content']) ? $avia_config['blog_content'] : "content";
  90. /*
  91. * retrieve slider, title and content for this post,...
  92. */
  93. $size = strpos($blog_style, 'big') ? (strpos($current_post['post_layout'], 'sidebar') !== false) ? 'entry_with_sidebar' : 'entry_without_sidebar' : 'square';
  94. if(!empty($avia_config['preview_mode']) && !empty($avia_config['image_size']) && $avia_config['preview_mode'] == 'custom') $size = $avia_config['image_size'];
  95. $current_post['slider'] = get_the_post_thumbnail($current_post['the_id'], 'full');
  96. if(is_single($initial_id) && get_post_meta( $current_post['the_id'], '_avia_hide_featured_image', true ) ) $current_post['slider'] = "";
  97. $current_post['title'] = get_the_title();
  98. $current_post['content'] = $blog_content == "content" ? get_the_content(__('Read more','avia_framework').'<span class="more-link-arrow"> &rarr;</span>') : get_the_excerpt();
  99. $current_post['content'] = $blog_content == "excerpt_read_more" ? $current_post['content'].'<div class="read-more-link"><a href="'.get_permalink().'" class="more-link">'.__('Read more','avia_framework').'<span class="more-link-arrow"> &rarr;</span></a></div>' : $current_post['content'];
  100. $current_post['before_content'] = "";
  101. /*
  102. * ...now apply a filter, based on the post type... (filter function is located in includes/helper-post-format.php)
  103. */
  104. $current_post = apply_filters( 'post-format-'.$current_post['post_format'], $current_post );
  105. $with_slider = empty($current_post['slider']) ? "" : "with-slider";
  106. /*
  107. * ... last apply the default wordpress filters to the content
  108. */
  109. $current_post['content'] = str_replace(']]>', ']]&gt;', apply_filters('the_content', $current_post['content'] ));
  110. $current_post['content'] = wp_trim_words( get_the_content(), 50, '...' );
  111. /*
  112. * Now extract the variables so that $current_post['slider'] becomes $slider, $current_post['title'] becomes $title, etc
  113. */
  114. extract($current_post);
  115. /*
  116. * render the html:
  117. */
  118. echo '<div class="flex_column av_one_half flex_column_div first avia-builder-el-3 el_after_av_hr el_before_av_one_half">';
  119. echo "<article class='".implode(" ", get_post_class('post-entry post-entry-type-'.$post_format . " " . $post_class . " ".$with_slider))."' ".avia_markup_helper(array('context' => 'entry','echo'=>false)).">";
  120. //default link for preview images
  121. $link = !empty($url) ? $url : get_permalink();
  122. //preview image description
  123. $desc = get_post( get_post_thumbnail_id() );
  124. if(is_object($desc)) $desc = $desc -> post_excerpt;
  125. $featured_img_desc = ( $desc != "" ) ? $desc : the_title_attribute( 'echo=0' );
  126. //on single page replace the link with a fullscreen image
  127. if(is_singular())
  128. {
  129. $link = avia_image_by_id(get_post_thumbnail_id(), 'large', 'url');
  130. }
  131. //echo preview image
  132. if($blog_global_style !== 'elegant-blog')
  133. {
  134. if(strpos($blog_style, 'big') !== false)
  135. {
  136. if($slider) $slider = '<a href="'.$link.'" title="'.$featured_img_desc.'">'.$slider.'</a>';
  137. if($slider) echo '<div class="big-preview '.$blog_style.'">'.$slider.'</div>';
  138. }
  139. if(!empty($before_content))
  140. echo '<div class="big-preview '.$blog_style.'">'.$before_content.'</div>';
  141. }
  142. echo "<div class='blog-meta'>";
  143. $blog_meta_output = "";
  144. $icon = '<span class="iconfont" '.av_icon_string($post_format).'></span>';
  145. if(strpos($blog_style, 'multi') !== false)
  146. {
  147. $gravatar = "";
  148. $link = get_post_format_link($post_format);
  149. if($post_format == 'standard')
  150. {
  151. $author_name = apply_filters('avf_author_name', get_the_author_meta('display_name', $post->post_author), $post->post_author);
  152. $author_email = apply_filters('avf_author_email', get_the_author_meta('email', $post->post_author), $post->post_author);
  153. $gravatar_alt = esc_html($author_name);
  154. $gravatar = get_avatar($author_email, '81', "blank", $gravatar_alt);
  155. $link = get_author_posts_url($post->post_author);
  156. }
  157. $blog_meta_output = "<a href='{$link}' class='post-author-format-type'><span class='rounded-container'>".$gravatar.$icon."</span></a>";
  158. }
  159. else if(strpos($blog_style, 'small') !== false)
  160. {
  161. $blog_meta_output = "<a href='{$link}' class='small-preview' title='{$featured_img_desc}'>".$slider.$icon."</a>";
  162. }
  163. echo apply_filters('avf_loop_index_blog_meta', $blog_meta_output);
  164. echo "</div>";
  165. echo "<div class='entry-content-wrapper clearfix {$post_format}-content'>";
  166. echo '<header class="entry-content-header">';
  167. $content_output = '<div class="entry-content" '.avia_markup_helper(array('context' => 'entry_content','echo'=>false)).'>';
  168. $content_output .= $content;
  169. $content_output .= '</div>';
  170. $taxonomies = get_object_taxonomies(get_post_type($the_id));
  171. $cats = '';
  172. $excluded_taxonomies = array_merge( get_taxonomies( array( 'public' => false ) ), array('post_tag','post_format') );
  173. $excluded_taxonomies = apply_filters('avf_exclude_taxonomies', $excluded_taxonomies, get_post_type($the_id), $the_id);
  174. if(!empty($taxonomies))
  175. {
  176. foreach($taxonomies as $taxonomy)
  177. {
  178. if(!in_array($taxonomy, $excluded_taxonomies))
  179. {
  180. $cats .= get_the_term_list($the_id, $taxonomy, '', ', ','').' ';
  181. }
  182. }
  183. }
  184. //elegant blog
  185. if( $blog_global_style == 'elegant-blog' )
  186. {
  187. if(!empty($cats))
  188. {
  189. echo '<span class="blog-categories minor-meta">';
  190. echo $cats;
  191. echo '</span>';
  192. $cats = "";
  193. }
  194. echo $title;
  195. echo '<span class="av-vertical-delimiter"></span>';
  196. //echo preview image
  197. if(strpos($blog_style, 'big') !== false)
  198. {
  199. if($slider) $slider = '<a href="'.$link.'" title="'.$featured_img_desc.'">'.$slider.'</a>';
  200. if($slider) echo '<div class="big-preview '.$blog_style.'">'.$slider.'</div>';
  201. }
  202. if(!empty($before_content))
  203. echo '<div class="big-preview '.$blog_style.'">'.$before_content.'</div>';
  204. echo $content_output;
  205. $cats = "";
  206. $title = "";
  207. $content_output = "";
  208. }
  209. echo $title;
  210. echo "<span class='post-meta-infos'>";
  211. //echo "<time class='date-container minor-meta updated' >".get_the_time(get_option('date_format'))."</time>";
  212. //echo "<span class='text-sep text-sep-date'> </span>";
  213. if ( get_comments_number() != "0" || comments_open() ){
  214. echo "<span class='comment-container minor-meta'>";
  215. comments_popup_link( "0 ".__('Comments','avia_framework'),
  216. "1 ".__('Comment' ,'avia_framework'),
  217. "% ".__('Comments','avia_framework'),'comments-link',
  218. "".__('Comments Disabled','avia_framework'));
  219. echo "</span>";
  220. echo "<span class='text-sep text-sep-comment'> </span>";
  221. }
  222. if(!empty($cats))
  223. {
  224. echo '<span class="blog-categories minor-meta list-view-meta">'.__('','avia_framework')." ";
  225. // Start Display the primary location number
  226. if ( $terms = get_the_terms( $post->ID, 'location' ) ) {
  227. foreach( $terms as $term ) {
  228. $term_link = get_term_link( $term );
  229. echo '<a href="' . esc_url( $term_link ) . '">' . $term->name . '</a><br />';
  230. echo '' . $cats . '<br />';
  231. //$office = get_term_meta( $term->term_id, 'address', true );
  232. //echo '' . $office . '<br />';
  233. $phone = get_term_meta( $term->term_id, 'phone', true );
  234. echo '' . $phone . '<br />';
  235. }
  236. }
  237. // End Display the primary location number
  238. echo '</span><span class="text-sep text-sep-cat"> </span>';
  239. }
  240. echo '<span class="blog-author minor-meta">'.__('by','avia_framework')." ";
  241. echo '<span class="entry-author-link" >';
  242. echo '<span class="vcard author"><span class="fn">';
  243. the_author_posts_link();
  244. echo '</span></span>';
  245. echo '</span>';
  246. echo '</span>';
  247. echo '</span>';
  248. echo '</header>';
  249. // echo the post content
  250. //echo $content_output;
  251. echo '<footer class="entry-footer">';
  252. $avia_wp_link_pages_args = apply_filters('avf_wp_link_pages_args', array(
  253. 'before' =>'<nav class="pagination_split_post">'.__('Pages:','avia_framework'),
  254. 'after' =>'</nav>',
  255. 'pagelink' => '<span>%</span>',
  256. 'separator' => ' ',
  257. ));
  258. wp_link_pages($avia_wp_link_pages_args);
  259. if(is_single() && !post_password_required())
  260. {
  261. //tags on single post
  262. if(has_tag())
  263. {
  264. echo '<span class="blog-tags minor-meta">';
  265. the_tags('<strong>'.__('Tags:','avia_framework').'</strong><span> ');
  266. echo '</span></span>';
  267. }
  268. //share links on single post
  269. avia_social_share_links();
  270. }
  271. do_action('ava_after_content', $the_id, 'post');
  272. echo '</footer>';
  273. echo "</div>";
  274. echo "<div class='post_author_timeline'></div>";
  275. echo av_blog_entry_markup_helper($current_post['the_id']);
  276. echo "</article>";
  277. echo "</div>";
  278. $post_loop_count++;
  279. endwhile;
  280. else:
  281. ?>
  282. <article class="entry">
  283. <header class="entry-content-header">
  284. <h1 class='post-title entry-title'><?php _e('Nothing Found', 'avia_framework'); ?></h1>
  285. </header>
  286. <p class="entry-content" <?php avia_markup_helper(array('context' => 'entry_content')); ?>><?php _e('Sorry, no posts matched your criteria', 'avia_framework'); ?></p>
  287. <footer class="entry-footer"></footer>
  288. </article>
  289. <?php
  290. endif;
  291. if(empty($avia_config['remove_pagination'] ))
  292. {
  293. echo "<div class='{$blog_style}'>".avia_pagination('', 'nav')."</div>";
  294. }
  295. }
  296. ?>
  297. <!--end content-->
  298. </main>
  299. <?php
  300. //get the sidebar
  301. $avia_config['currently_viewing'] = 'page';
  302. //get_sidebar();
  303. ?>
  304. </div><!--end container-->
  305. </div><!-- close default .container_wrap element -->
  306. <?php get_footer(); ?>