質問編集履歴

1

ソースコードの前後を記入

2021/07/10 05:30

投稿

furetarou
furetarou

スコア0

test CHANGED
File without changes
test CHANGED
@@ -20,11 +20,71 @@
20
20
 
21
21
  ### 該当のソースコード
22
22
 
23
-
23
+ function start_el(&$ output、$ object、$ depth = 0、$ args = Array、$ current_object_id = 0)
24
24
 
25
25
  ```ここに言語名を入力
26
26
 
27
+ // Extend WP's Walker class to properly navigate the category hierarchy...
28
+
29
+ class Simple_Archive_Category_Walker extends Walker {
30
+
31
+ // Variables needed by the WP Walker class.
32
+
33
+ var $tree_type = 'category';
34
+
35
+ var $db_fields = array ('parent' => 'parent', 'id' => 'term_id');
36
+
37
+
38
+
39
+ // Variables used by the Simple Archive plug-in.
40
+
41
+ var $done_post_ids = ' ';
42
+
43
+ var $comment_count = 0;
44
+
45
+ var $post_count = 0;
46
+
47
+
48
+
49
+ // Output a new element (Category)...
50
+
27
- function start_el(&$ output、$ object、$ depth = 0、$ args = Array、$ current_object_id = 0)
51
+ function start_el(&$ output、$ object、$ depth = 0、$ args = Array、$ current_object_id = 0)
52
+
53
+ {
54
+
55
+ global $simple_archive_options;
56
+
57
+
58
+
59
+ $args = wp_parse_args($r);
60
+
61
+
62
+
63
+ // Only show category heading if there are posts to show; keep count of posts...
64
+
65
+ $posts_to_show = 0;
66
+
67
+
68
+
69
+ // Get posts for this category.
70
+
71
+ $posts = get_posts('category=' . $category->term_id . '&orderby=post_date&order=DESC&numberposts=9999');
72
+
73
+
74
+
75
+ // Build a list of the post IDs that will be shown.
76
+
77
+ foreach($posts as $post) {
78
+
79
+ setup_postdata($post);
80
+
81
+ if(!strpos($this->done_post_ids, '+' . $post->ID . '+') || $simple_archive_options['list_post_once'] != 'on') {
82
+
83
+ $posts_to_show++;
84
+
85
+ }
86
+
87
+ }
28
88
 
29
89
  ```
30
90