Created
June 15, 2020 06:00
-
-
Save fencermonir/e2300db8934f5f720bd486349a82a58c to your computer and use it in GitHub Desktop.
LostEagle New Search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* news Search | |
*/ | |
function news_search() | |
{ | |
parse_str($_POST['form'], $output); | |
$order = isset($_POST['order']) ? $_POST['order'] : 'ASC'; | |
$args = array( | |
'post_type' => 'post', | |
'post_status' => 'publish', | |
'posts_per_page' => get_option('posts_per_page'), | |
's' => $output['s'], | |
'order' => $order, | |
'order_by' => 'date' | |
); | |
$wp_query = new WP_Query($args); | |
?> | |
<div class="container"> | |
<div class="row news-container"> | |
<?php | |
if ($wp_query->have_posts()) : | |
while ($wp_query->have_posts()) : $wp_query->the_post(); | |
?> | |
<div class="col-xl-3 col-lg-4 col-md-6 col-sm-6 col-xs-12"> | |
<article id="post-<?php the_ID(); ?>" <?php post_class('blog-post'); ?>> | |
<a href="<?php the_permalink(); ?>" class="news-post"> | |
<figure class="media"> | |
<?php | |
if (has_post_thumbnail()) { | |
the_post_thumbnail('le_post_thumb', array('class' => 'img-fluid')); | |
} else { | |
printf('<img src="%s" class="img-fluid" alt="%s">', esc_url(get_theme_file_uri('images/placeholder-post.jpg')), get_bloginfo()); | |
} | |
?> | |
</figure> | |
<div class="content"> | |
<?php the_title('<h3 class="title text-uppercase">', '</h3>'); ?> | |
<?php if (has_excerpt()) : ?> | |
<?php printf('<p class="fs-sm">%s</p>', get_the_excerpt()); ?> | |
<?php endif; ?> | |
<svg class="icon-caret" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40"> | |
<g fill="none" stroke="#fff" stroke-width="1.5" stroke-linejoin="round" stroke-miterlimit="10"> | |
<circle class="icon-caret--circle" cx="19" cy="19" r="18"></circle> | |
<path class="icon-caret--path" d="M13,27.829V8l17.468,9.915Z" fill="#fff" stroke="none"></path> | |
</g> | |
</svg> | |
</div> | |
</a><!-- /news-post --> | |
</article> | |
</div> <!-- /repeat item --> | |
<?php | |
endwhile; | |
else : ?> | |
<div class="entry-content" style="padding: 30px 0 50px"> | |
<h4 class="no-content"><?php echo esc_attr('Not found posts!!!'); ?></h4> | |
</div> | |
<?php | |
endif; | |
?> | |
</div> | |
<div class="row"> | |
<div class="col-md-12 col-sm-12 col-xs-12 text-center"> | |
<?php | |
if ($wp_query->max_num_pages > 1) { | |
echo '<button class="btn blog_loadmore" data-page="1" data-total_page="' . $wp_query->max_num_pages . '" data-keyword="'.$output['s'].'" data-order="'.$order.'">Load More</button>'; | |
} | |
wp_reset_postdata(); | |
?> | |
</div> | |
</div> | |
<div class="row"> | |
<div class="col-md-12 col-sm-12 col-xs-12"> | |
<div class="horizontal-linebar"></div> | |
</div> | |
</div> | |
</div> | |
<?php | |
die(); | |
} | |
add_action('wp_ajax_nopriv_news_search', 'news_search'); | |
add_action('wp_ajax_news_search', 'news_search'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment