-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsearch.php
99 lines (88 loc) · 3.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php get_header(); ?>
<?php
$search_string = esc_attr( trim( get_query_var('s') ) );
$wp_user_query = new WP_User_Query( array(
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'first_name',
'value' => $search_string,
'compare' => 'LIKE'
),
array(
'key' => 'last_name',
'value' => $search_string,
'compare' => 'LIKE'
)
)
) );
?>
<section>
<div class="container">
<div class="reading-content">
<form action="<?php echo home_url() ?>/" method="get" class="mb-4">
<input class="form-control alt" type="text" name="s" id="search" value="<?php the_search_query(); ?>" placeholder="<?php esc_html_e( 'Search', 'hfansite' ); ?>" />
</form>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="card search">
<?php if ( has_post_thumbnail() ) : ?>
<div class="thumb">
<img src="<?php echo get_the_post_thumbnail_url(); ?>">
</div>
<?php else: ?>
<?php if( 'post' === get_post_type() ): ?>
<div class="thumb">
<img src="<?php bloginfo('template_directory'); ?>/assets/image/default-cover.png" alt="<?php the_title(); ?>" />
</div>
<?php elseif( 'forum' === get_post_type() ): ?>
<div class="thumb box user">
<?php echo get_avatar( get_the_author_meta( 'ID' ), 150 ); ?>
</div>
<?php elseif( 'destaque' === get_post_type() ): ?>
<div class="thumb box user pixel">
<img src="https://www.habbo.com.br/habbo-imaging/avatarimage?&user=<?php the_title(); ?>&action=std&direction=2&head_direction=2&img_format=png&gesture=std&size=b" alt="<?php the_title(); ?>">
</div>
<?php else: ?>
<div class="thumb box pixel">
<img src="<?php bloginfo("template_directory")?>/assets/image/box.png">
</div>
<?php endif; ?>
<?php endif; ?>
<div class="w-100">
<?php if( 'post' === get_post_type() ): ?>
<div class="mb-1"><a href="#"><strong><?php foreach((get_the_category()) as $category) { echo $category->cat_name . ' '; } ?></strong></a></div>
<?php endif; ?>
<h5 class="card-title mb-1"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5>
<div class="card-text mb-1">
<?php if ( has_excerpt() ): ?>
<?php echo the_excerpt(); ?>
<?php else: ?>
<?php $content = wp_strip_all_tags( get_the_content() ); echo mb_strimwidth($content, 0, 150, '...');?>
<?php endif; ?>
</div>
<?php if( 'post' === get_post_type() ): ?>
<time class="text-muted"><?php echo get_the_date(); ?></time>
<?php elseif( 'evento' === get_post_type() ): ?>
<time class="text-muted"><?php echo get_the_date(); ?></time>
<?php elseif( 'forum' === get_post_type() ): ?>
<time class="text-muted"><?php echo get_the_date(); ?></time>
<?php elseif( 'galeria' === get_post_type() ): ?>
<time class="text-muted"><?php echo get_the_date(); ?></time>
<?php endif; ?>
</div>
</div>
<?php endwhile?>
<?php else: ?>
<div class="text-center" style="padding: 5rem 0">
<h2><?php esc_html_e( 'No results found.', 'hfansite' ); ?></h2>
<p class="text-muted"><?php
/* translators: %s: search term */
printf( esc_attr__( 'Your search for "%s" returned no results.', 'hfansite' ), '<strong>' . get_search_query() . '</strong>' );
?></p>
</div>
<?php endif; ?>
<div class="pagination"><?php the_pagination(); ?></div>
</div>
</div>
</section>
<?php get_footer(); ?>