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

回答編集履歴

2

誤字修正

2019/09/04 02:20

投稿

junjun1479
junjun1479

スコア7

answer CHANGED
@@ -2,7 +2,7 @@
2
2
  [こちらの記事](http://wpcj.net/1359)を参考にカスタマイズして、
3
3
  以下のコードをfunctions.phpに記述したら、特定のカスタムタクソノミのタームに属するカスタム投稿を検索結果から除外できました。
4
4
  ```php
5
- function search_exclude_custom_post_type( $query ) {
5
+ function search_exclude_custom_taxonomy_type( $query ) {
6
6
  if ( $query->is_search() && $query->is_main_query() && ! is_admin() ) {
7
7
  $taxquery = array(
8
8
  array(
@@ -15,5 +15,5 @@
15
15
  $query->set( 'tax_query' , $taxquery );
16
16
  }
17
17
  }
18
- add_filter( 'pre_get_posts', 'search_exclude_custom_post_type' );
18
+ add_filter( 'pre_get_posts', 'search_exclude_custom_taxonomy_type' );
19
19
  ```

1

参考サイト追加

2019/09/04 02:20

投稿

junjun1479
junjun1479

スコア7

answer CHANGED
@@ -1,4 +1,6 @@
1
+ 自己解決しました。
2
+ [こちらの記事](http://wpcj.net/1359)を参考にカスタマイズして、
1
- 自己解決しました。以下のコードをfunctions.phpに記述したら、特定のカスタムタクソノミのタームに属するカスタム投稿を検索結果から除外できました。
3
+ 以下のコードをfunctions.phpに記述したら、特定のカスタムタクソノミのタームに属するカスタム投稿を検索結果から除外できました。
2
4
  ```php
3
5
  function search_exclude_custom_post_type( $query ) {
4
6
  if ( $query->is_search() && $query->is_main_query() && ! is_admin() ) {