teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

変数のスペルミスを修正

2017/12/31 03:16

投稿

maifukuhara
maifukuhara

スコア83

title CHANGED
File without changes
body CHANGED
@@ -31,7 +31,7 @@
31
31
  functions.phpに記述したいと思っています。
32
32
 
33
33
  WPDocsを参考に下記を書いてみたのですが、
34
- うまくいかないようです。
34
+ うまく抽出されないようです。
35
35
 
36
36
  ```php
37
37
  //functions.php
@@ -40,7 +40,7 @@
40
40
  function my_remove_cat()
41
41
  {
42
42
  global $wp_query;
43
- $wp_query->query_posts['tax_query'] = array(
43
+ $wp_query->query_vars['tax_query'] = array(
44
44
  'relation' => 'AND',
45
45
  array(
46
46
  'taxonomy' => 'my-custmon-category',
@@ -52,13 +52,6 @@
52
52
  );
53
53
  }
54
54
  ```
55
- ■エラー
56
- Notice: Indirect modification of overloaded property
57
- WP_Query::$query_posts has no effect in
58
- \wordpress\wp-content\themes\twentysixteen\functions.php on line xxx
59
55
 
60
- 配列の書き換えができない、という旨なのでしょうが、
61
- 対応法がわからない状況です。
62
-
63
56
  アドバイスをいただけないでしょうか。
64
57
  よろしくお願いします。