質問編集履歴

2

誤字

2020/08/19 03:43

投稿

shimon11
shimon11

スコア50

test CHANGED
File without changes
test CHANGED
@@ -58,7 +58,7 @@
58
58
 
59
59
  ```
60
60
 
61
- function not-rss(){
61
+ function not_rss(){
62
62
 
63
63
  $wp_query = new WP_Query(array(
64
64
 

1

追記

2020/08/19 03:43

投稿

shimon11
shimon11

スコア50

test CHANGED
File without changes
test CHANGED
@@ -47,3 +47,61 @@
47
47
  'value' => 'yes',
48
48
 
49
49
  ```
50
+
51
+
52
+
53
+ ### 試したこと
54
+
55
+
56
+
57
+ functions.phpに追加
58
+
59
+ ```
60
+
61
+ function not-rss(){
62
+
63
+ $wp_query = new WP_Query(array(
64
+
65
+ 'post_type' => 'post',
66
+
67
+ 'post_status' => 'publish',
68
+
69
+ 'order' => 'DESC',
70
+
71
+ 'orderby' => 'date',
72
+
73
+ 'meta_query' => array(
74
+
75
+ array(
76
+
77
+ 'key' => 'not-rss',
78
+
79
+ 'value' => 'yes',
80
+
81
+ 'compare' => 'EXISTS',
82
+
83
+ ),
84
+
85
+ ),
86
+
87
+ ));
88
+
89
+ while ($wp_query->have_posts()) {
90
+
91
+ $post_id = get_the_ID();
92
+
93
+ $not-rss = get_post_meta($post_id, 'not-rss', true);
94
+
95
+ if ($not-rss === 'yes'){
96
+
97
+ remove_action('wp_head', 'feed_links');
98
+
99
+ remove_action('wp_head', 'feed_links_extra');
100
+
101
+ }
102
+
103
+ }
104
+
105
+ }
106
+
107
+ ```