WordPress Custom Theme Search
WordPress Custom Theme Search. Bu yazımızda wordpress custom tema yaparken search kısmında kullanılan kod listesi bulunmaktadır. Bu kodlar ile search kısmını yapabilirsiniz.
<?php get_header();?>
<content>
<div class="content">
<h1 class="c_text">
Blog
</h1>
<hr class="space_2">
<?php get_search_form(); ?>
<div id="img-container" class="c_text">
<!-- #################################### -->
<?php
$s=get_search_query();
$the_query = new WP_Query(
array(
's' =>$s,
'post_type'=> 'post',
'post_status' => 'publish',
'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1,
// 'posts_per_page' => 1,
// 'order' => '',
// 'orderby' => 'title',
// 'tag' => '',
// 'ignore_sticky_posts' => 1,
)
);
if ( $the_query->have_posts() ) {
_e("<h2>Arama sonuçları: ".get_query_var('s')."</h2>");
while ( $the_query->have_posts() ) {
$the_query->the_post();
?>
<span class="bloglistbox">
<a href="<?php the_permalink() ?>">
<?php if (has_post_thumbnail()): ?>
<img src="<?php the_post_thumbnail_url() ?>" alt="logo">
<?php endif ?>
<h2><?php the_title(); ?></h2>
<p class="times">
<?php echo get_the_date(); ?>
</p>
</a>
</span>
<?php
}
$num_posts = wp_count_posts('post')->publish;
if ($num_posts > 5) {
kriesi_pagination($the_query->max_num_pages);
}
}else{
?>
<?php _e("<h2>Arama sonuçları: ".get_query_var('s')."</h2>");?>
<span class="blogbox">
<div class="parg c_text">
<h2>Hiçbirşey Bulunamadı!</h2>
<p>Üzgünüz, ancak arama kriterlerinize uyan hiçbir şey bulunamadı. Lütfen farklı anahtar kelimelerle tekrar deneyin.</p>
</div>
</span>
<?php } ?>
</div>
</div>
</content>
<?php get_footer();?>
Bir cevap yaz