-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsingle.php
More file actions
executable file
·75 lines (65 loc) · 2.64 KB
/
single.php
File metadata and controls
executable file
·75 lines (65 loc) · 2.64 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
<?php get_header() ?>
<div class="container">
<div class="row">
<?php
$sidebar_location = fw_get_db_customizer_option('sidebar_setting');
if($sidebar_location === 'left') {get_sidebar();}
?>
<section id="site-content" class="site-content" role="region" aria-labelledby="page-title-<?php echo $post->ID ?>">
<?php
do_action("wally_before_post_loop");
if(have_posts()):
while(have_posts()): the_post();
get_template_part('parts/posts/single');
endwhile;
endif;
do_action("wally_after_post_loop");
comments_template();
?>
</section>
<?php if($sidebar_location === 'right') {get_sidebar();} ?>
</div>
<?php
$categories = wp_get_post_categories($post->ID);
$tags = wp_get_post_tags($post->ID);
$args =
array(
'tax_query' => array(
'relation' => 'OR',
array(
'taxonomy' => 'category',
'field' => 'id',
'terms' => $categories,
),
array(
'taxonomy' => 'tag',
'field' => 'id',
'terms' => $tags,
),
),
'posts_per_page' => 2,
'post__not_in' => array($post->ID)
);
$related = new WP_Query( $args );
if($related->have_posts()): ?>
<div class="row">
<div class="related-posts">
<h2 class="related-posts__title"><?php _e('Relaterade artiklar', 'wally-theme') ?></h2>
<?php
do_action("wally_before_related_loop");
while($related->have_posts()): $related->the_post();
$relation = false;
if(array_intersect($categories, wp_get_post_categories($post->ID))) {
$relation = 'category';
} else if(array_intersect($tags, wp_get_post_tags($post->ID))) {
$relation = 'tag';
}
include(locate_template(('parts/posts/related.php')));
endwhile; wp_reset_postdata();
do_action("wally_after_related_loop");
?>
</div>
</div>
<?php endif ?>
</div>
<?php get_footer() ?>