質問編集履歴

1

コードを添付

2019/09/01 11:26

投稿

akama_666
akama_666

スコア14

test CHANGED
File without changes
test CHANGED
@@ -19,3 +19,59 @@
19
19
 
20
20
 
21
21
  他に必要な情報がありましたら、お答えしますのでよろしくお願いいたします。
22
+
23
+
24
+
25
+ 追記↓
26
+
27
+
28
+
29
+ ```PHP
30
+
31
+ <?php if(has_category() ) {
32
+
33
+ $cats =get_the_category();
34
+
35
+ $catkwds = array();
36
+
37
+ foreach($cats as $cat){
38
+
39
+ $catkwds[] = $cat->term_id;
40
+
41
+ }
42
+
43
+ } ?>
44
+
45
+ <?php $args = array(
46
+
47
+ 'post_type' => 'post',
48
+
49
+ 'posts_per_page' => '8',
50
+
51
+ 'post__not_in' =>array( $post->ID ),
52
+
53
+ 'category__in' => $catkwds,
54
+
55
+ 'orderby' => 'rand'
56
+
57
+ );
58
+
59
+ $my_query = new WP_Query( $args );?>
60
+
61
+ <?php while ( $my_query->have_posts() ) : $my_query->the_post(); ?>
62
+
63
+ <a href="<?php the_permalink(); ?>">
64
+
65
+ <div class="rcolumn cf">
66
+
67
+ <img src="<?php the_post_thumbnail_url(); ?>">
68
+
69
+ </div>
70
+
71
+ <h3 class="title"><?php the_title(); ?></h3>
72
+
73
+ </a>
74
+
75
+ <?php endwhile;?>
76
+
77
+ ```