-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.php
69 lines (61 loc) · 2.52 KB
/
search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php get_header(); ?>
<main id="main">
<header class="mb-3">
<a href="#" class="burger-btn d-block d-xl-none">
<i class="bi bi-justify fs-3"></i>
</a>
</header>
<section class="section">
<div class="title-search-container">
<div class="title-search">
<h2><?php printf(__('Hasil pencarian untuk:')); ?></h2>
<p><?php echo sprintf('"%s"', get_search_query()); ?></p>
</div>
</div>
<?php if (have_posts()) : ?>
<ul class="post-list">
<?php while (have_posts()) : the_post(); ?>
<li>
<?php if (has_post_thumbnail()) : ?>
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail('large', array('srcset' => wp_get_attachment_image_srcset(get_post_thumbnail_id(), 'large'))); ?>
</a>
<?php endif; ?>
<!-- Menampilkan kategori utama -->
<div class="post-category">
<?php
$categories = get_the_category();
if (!empty($categories)) {
echo '<p>in <a href="' . esc_url(get_category_link($categories[0]->term_id)) . '">' . esc_html($categories[0]->name) . '</a></p>';
}
?>
</div>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<p><?php echo wp_trim_words(get_the_excerpt(), 10); ?></p>
<span>
<div class="update-post-date">
<p>Updated</p>
</div>
<?php echo date('M j, Y', strtotime(get_the_modified_date())); ?>
</span>
</li>
<?php endwhile; ?>
</ul>
<!-- Paginasi -->
<div class="pagination">
<?php
echo paginate_links(array(
'total' => $wp_query->max_num_pages,
'current' => max(1, get_query_var('paged')),
'prev_text' => __('« Previous'),
'next_text' => __('Next »'),
));
?>
</div>
<?php else : ?>
<p>No posts found for "<strong><?php echo get_search_query(); ?></strong>". Try another search.</p>
<?php endif; ?>
<?php wp_reset_postdata(); ?>
</section>
</div>
<?php get_footer(); ?>