This repository was archived by the owner on Mar 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsingle.php
More file actions
48 lines (43 loc) · 1.36 KB
/
single.php
File metadata and controls
48 lines (43 loc) · 1.36 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
<?php get_header(); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="u-container u-section">
<h1><?php the_title(); ?></h1>
<?php the_content(); ?>
<p>Posted on <?php echo get_the_time('jS F Y'); ?></p>
</div>
<div class="u-container u-section">
<h2>Related articles</h2>
<ul class="u-list-unstyled">
<?php
$$orig_post = $post;
global $post;
$tags = wp_get_post_tags($post->ID);
if ($tags) {
$tag_ids = array();
foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
$args=array(
'tag__in' => $tag_ids,
'post__not_in' => array($post->ID),
'posts_per_page'=>5, // Number of related posts to display.
'caller_get_posts'=>1,
'orderby' => 'rand'
);
$my_query = new wp_query( $args );
while( $my_query->have_posts() ) {
$my_query->the_post();
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php }
}
$post = $orig_post;
wp_reset_query();
?>
</ul>
</div>
<?php endwhile; else : ?>
<div class="u-container">
<h1>Not Found</h1>
<p>Sorry, but you are looking for something that isn't here.</p>
</div>
<?php endif; ?>
<?php get_footer(); ?>