Advertisement
Guenni007

loop-search

Apr 22nd, 2021
1,044
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.93 KB | None | 0 0
  1. <?php
  2. if ( ! defined( 'ABSPATH' ) ) {  exit;  }    // Exit if accessed directly
  3.  
  4. global $avia_config;
  5.  
  6.  
  7. // check if we got posts to display:
  8. if (have_posts()) :
  9.     $first = true;
  10.  
  11.     $counterclass = "";
  12.     $post_loop_count = 1;
  13.     $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
  14.     if($page > 1) $post_loop_count = ((int) ($page - 1) * (int) get_query_var('posts_per_page')) +1;
  15.     $blog_style = avia_get_option('blog_style','multi-big');
  16.  
  17.     while ( have_posts() ) : the_post();
  18.  
  19.  
  20.     $the_id         = get_the_ID();
  21.     $parity         = $post_loop_count % 2 ? 'odd' : 'even';
  22.     $last           = count($wp_query->posts) == $post_loop_count ? " post-entry-last " : "";
  23.     $post_class     = "post-entry-".$the_id." post-loop-".$post_loop_count." post-parity-".$parity.$last." ".$blog_style;
  24.     $post_format    = get_post_format() ? get_post_format() : 'standard';
  25.  
  26.     ?>
  27.  
  28.     <article <?php post_class('post-entry post-entry-type-'.$post_format . " " . $post_class . " "); avia_markup_helper(array('context' => 'entry')); ?>>
  29.         <div class="entry-content-wrapper clearfix <?php echo $post_format; ?>-content">
  30.  
  31.             <header class="entry-content-header">
  32.                 <?php
  33.  // new entries for thumbnail and link              
  34.                 $searchimage = get_the_post_thumbnail( $the_id, 'large' );
  35.                 echo "<a class='slide-image search_image' href='".get_permalink()."'><span class='search-result-image'>{$searchimage}</span></a>";
  36.                 echo "<span class='search-result-counter {$counterclass}'>{$post_loop_count}</span>";
  37.                
  38.                 $default_heading = 'h2';
  39.                 $args = array(
  40.                             'heading'       => $default_heading,
  41.                             'extra_class'   => ''
  42.                         );
  43.  
  44.                 /**
  45.                  * @since 4.5.5
  46.                  * @return array
  47.                  */
  48.                 $args = apply_filters( 'avf_customize_heading_settings', $args, 'loop_search', array() );
  49.  
  50.                 $heading = ! empty( $args['heading'] ) ? $args['heading'] : $default_heading;
  51.                 $css = ! empty( $args['extra_class'] ) ? $args['extra_class'] : '';
  52.                
  53.                 //echo the post title
  54.                 $markup = avia_markup_helper(array('context' => 'entry_title','echo'=>false));
  55.                 echo "<{$heading} class='post-title entry-title {$css}'><a title='".the_title_attribute('echo=0')."' href='".get_permalink()."' $markup>".get_the_title()."</a></{$heading}>";
  56.  
  57.                 ?>
  58.                 <span class='post-meta-infos'>
  59.                     <time class='date-container minor-meta updated' <?php avia_markup_helper(array('context' => 'entry_time')); ?>>
  60.             <?php the_time( get_option( 'date_format' ) ); ?>
  61.                     </time>
  62.                     <?php
  63.                     if(get_post_type() !== "page")
  64.                     {
  65.                         if ( get_comments_number() != "0" || comments_open() )
  66.                         {
  67.                             echo "<span class='text-sep'>/</span>";
  68.                             echo "<span class='comment-container minor-meta'>";
  69.                             comments_popup_link(  "0 ".__('Comments','avia_framework'),
  70.                                                   "1 ".__('Comment' ,'avia_framework'),
  71.                                                   "% ".__('Comments','avia_framework'),'comments-link',
  72.                                                   "".__('Comments Disabled','avia_framework'));
  73.                             echo "</span>";
  74.                         }
  75.                     }
  76.  
  77.  
  78.                     $taxonomies  = get_object_taxonomies(get_post_type($the_id));
  79.                     $cats = '';
  80.                     $excluded_taxonomies = array_merge( get_taxonomies( array( 'public' => false ) ), array('post_tag','post_format') );
  81.                     $excluded_taxonomies = apply_filters('avf_exclude_taxonomies', $excluded_taxonomies, get_post_type($the_id), $the_id);
  82.                    
  83.                     if(!empty($taxonomies))
  84.                     {
  85.                         foreach($taxonomies as $taxonomy)
  86.                         {
  87.                             if(!in_array($taxonomy, $excluded_taxonomies))
  88.                             {
  89.                                 $cats .= get_the_term_list($the_id, $taxonomy, '', ', ','').' ';
  90.                             }
  91.                         }
  92.                     }
  93.  
  94.                     if(!empty($cats))
  95.                     {
  96.                         echo "<span class='text-sep'>/</span>";
  97.                         echo '<span class="blog-categories minor-meta">'.__('in','avia_framework')." ";
  98.                         echo $cats;
  99.                         echo '</span>';
  100.                     }
  101.  
  102.                     ?>
  103.  
  104.                 </span>
  105.             </header>
  106.  
  107.             <?php
  108.                 echo '<div class="entry-content" '.avia_markup_helper(array('context' => 'entry_content','echo'=>false)).'>';
  109.                 $excerpt = trim(get_the_excerpt());
  110.                 if(!empty($excerpt))
  111.                 {
  112.                     the_excerpt();
  113.                 }
  114.                 else
  115.                 {
  116.                     $excerpt = strip_shortcodes( get_the_content() );
  117.                     $excerpt = apply_filters('the_excerpt', $excerpt);
  118.                     $excerpt = str_replace(']]>', ']]&gt;', $excerpt);
  119.                     echo $excerpt;
  120.                 }
  121.                 echo '</div>';
  122.             ?>
  123.         </div>
  124.  
  125.         <footer class="entry-footer"></footer>
  126.        
  127.         <?php do_action('ava_after_content', $the_id, 'loop-search'); ?>
  128.     </article><!--end post-entry-->
  129.  
  130.     <?php
  131.  
  132.  
  133.         $first = false;
  134.         $post_loop_count++;
  135.         if($post_loop_count >= 100) $counterclass = "nowidth";
  136.     endwhile;
  137.     else:
  138.  
  139.  
  140. ?>
  141.  
  142.     <article class="entry entry-content-wrapper clearfix" id='search-fail'>
  143.             <p class="entry-content" <?php avia_markup_helper(array('context' => 'entry_content')); ?>>
  144.                 <strong><?php _e('Nothing Found', 'avia_framework'); ?></strong><br/>
  145.                <?php _e('Sorry, no posts matched your criteria. Please try another search', 'avia_framework'); ?>
  146.             </p>
  147.  
  148.             <div class='hr_invisible'></div>
  149.  
  150.             <section class="search_not_found">
  151.                 <p><?php _e('You might want to consider some of our suggestions to get better results:', 'avia_framework'); ?></p>
  152.                 <ul>
  153.                     <li><?php _e('Check your spelling.', 'avia_framework'); ?></li>
  154.                     <li><?php _e('Try a similar keyword, for example: tablet instead of laptop.', 'avia_framework'); ?></li>
  155.                     <li><?php _e('Try using more than one keyword.', 'avia_framework'); ?></li>
  156.                 </ul>
  157.         <?php
  158.        
  159.         /**
  160.          * Additional output when nothing found in search
  161.          *
  162.          * @since 4.1.2
  163.          * @added_by günter
  164.          * @return string           cutom HTML escaped for echo | ''
  165.          */
  166.         $custom_no_earch_result = apply_filters( 'avf_search_results_pagecontent', '' );
  167.         echo $custom_no_earch_result;
  168.        
  169.        
  170.         echo '</section>';
  171.     echo "</article>";
  172.  
  173.     endif;
  174.     echo avia_pagination('', 'nav');
  175.    
  176.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement