content-search.php
1.92 KB
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
<?php
/**
* Search results partial template
*
* @package Understrap
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
$img ="";
$imgid = get_post_thumbnail_id();
$post_type = get_post_type(get_the_ID());
$permalink = get_permalink();
$target = '';
$excerpt = get_the_excerpt();
if($post_type == 'attachment') {
$permalink = wp_get_attachment_url( get_the_ID());
if ( wp_attachment_is_image(get_the_ID()) ) {
$img = wp_get_attachment_url( get_the_ID());
}
$target = 'target="_blank"';
$excerpt = get_post_meta ( get_the_ID(), 'description', true );
}else if($post_type == 'documents'){
$permalink = get_post_meta( get_the_ID(), 'document_link', true );
$target = 'target="_blank"';
$excerpt = get_post_meta ( get_the_ID(), 'description', true );
}
$term_list = array();
$terms = wp_get_post_terms( $post->ID, 'document-format');
if ( !empty( $terms ) && !is_wp_error( $terms ) ){
foreach ( $terms as $term ) {
$term_list = $term->name;
}
}
?>
<article <?php post_class(); ?> id="post-<?php the_ID(); ?>">
<a href='<?php echo $permalink; ?>' <?php echo $target; ?> class='outside-a'>
<?php
if($imgid || $img):
?>
<div class='photo'>
<?php
if($imgid) {
$image = wp_get_attachment_image_src($imgid, 'medium');
$image = $image[0];
} else if($img ) {
$image = $img;
}
$image_alt = get_post_meta ( $imgid, '_wp_attachment_image_alt', true );
if(!$image_alt){
$image_alt = get_the_title($imgid);
}
?>
<img src='#' data-src="<?= $image ?>" class='lazy' alt='<?= $image_alt ?>' />
</div>
<?php endif; ?>
<div class='content'>
<header class="entry-header">
<h2 class="<?php echo $term_list;?>"><?= the_title() ?></h2>
</header><!-- .entry-header -->
<div class="entry-summary" >
<?= str_replace("[...]Read More...", "",wp_strip_all_tags($excerpt, true)); ?>
</div><!-- .entry-summary -->
</div>
</a>
</article><!-- #post-## -->