-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
127 lines (103 loc) · 3.12 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
/**
* The template for displaying search results pages
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#search-result
*
* @package youhadmeat_theme
*/
get_header();
?>
<section id="primary" class="content-area">
<main id="main" class="site-main">
<style>
.searchtext{
position: block;
text-align: center;
margin-top: 50px;
}
.search-leading{
position: block;
text-align: center;
}
.search-trailing{
text-align: center;
}
.page-content p{
text-align: center;
}
</style>
<?php if ( have_posts() ) : ?>
<header class="page-header">
<h1 class="searchtext">
<?php
/* translators: %s: search query. */
printf( esc_html__( 'Search Results for: %s', 'youhadmeat_theme' ), '<div class="search-trailing">' . get_search_query() . '</div>' );
?>
</h1>
</header><!-- .page-header -->
<?php
echo '<div class="card-deck">';
/*echo '<div class="card-deck-header">
<div class="card-deck-header-title"></div>
</div>';*/
echo '<ul class="card-deck__container">';
/* Start the Loop */
while ( have_posts() ) :
the_post();
$ParentCategory = "";
$category = get_the_category();
foreach($category as $curcat){
if($curcat->parent == 0){
$ParentCategory = $curcat;
}
}
$excerptStr = (strlen(get_the_excerpt()) > 40) ? substr(get_the_excerpt(),0,40).'...' :get_the_excerpt();
$pageTitle = get_the_title();
$comingsoon = get_post_meta( get_the_id(),'comingsoon', true );
$postUrl = get_permalink(get_the_id());
if($comingsoon){
$pageTitle = 'Coming Soon';
$excerptStr = '';
$postUrl = '##';
}
$authorUrl = ''.get_site_url().'/'.get_the_author_meta('user_nicename').'';
echo' <li class="card category--'.$curcat->slug.'">
<a href="'.$postUrl.'">
<div class="card__header">';
if(get_post_type() == 'post'){
echo'<div class="card__header-category category--'.$ParentCategory->slug.'">
<div class="card__header-category__title">'.strtoupper($ParentCategory->name).'</div>
<div class="card__header-category__icon"></div>
</div>';//'</div>
}
echo '</div>
<img class="a-card-image-zoom" src="'.get_the_post_thumbnail_url(get_the_id(), 'medium').'" />
<div class="card__content">
<div class="card__content-title category--'.$ParentCategory->slug.'">'.$pageTitle.'</div>
<div class="card__content-excerpt">
'.$excerptStr.'
</div>
<div class="card__author">
<a href="'.$authorUrl.'">
'.get_wp_user_avatar(get_the_author_meta('ID'),'small').'
</a>
</div>
</div>
</a>
</li>';
endwhile;
echo '</ul>';//category-content
echo '</div>';//category-wrapper
the_posts_navigation();
else :
get_template_part( 'template-parts/content', 'none' );
endif;
?>
</main><!-- #main -->
</section><!-- #primary -->
<script>
document.getElementById("site-navigation").style.top = "0";
</script>
<?php
get_footer();