###実現したいこと
WordPressで全てのタームを取得するとき、そのタームの「ID」と「discription」を取得したいです。
###発生している問題・エラーメッセージ
下記の「試したこと」を実行するとこのようなエラーが吐き出されます。
<div id="error"> <p class="wpdberror"> <strong>WordPress データベースエラー:</strong> [You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ' FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id 'at line 1] <br /> <code> SELECT FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('music_tag') AND tt.count > 0 ORDER BY tt.count ASC </code> </p> </div> []
###試したこと
下記の『'fields' => 'id=>discription'』という指定では上記エラーでした。
もちろん 『'fields' => 'all'』にすれば「discription」や他のデータまですべて含めて取得できますが、他のデータがいりません。
どうすれば「ID」と「discription」だけを取得できますでしょうか?
php
1 $args = array( 2 'orderby' => 'count', // 多い順 3 'order' => 'ASC', 4 'hide_empty' => true, 5 'number' => '', // 最大個数 6 'fields' => 'id=>discription', // エラーになる 7 'hierarchical' => false, // 子タームはない 8 ); 9 10 $terms = get_terms( $taxonomies, $args );
###補足
意図しているのはターム検索の利便性アップです。
まず「FB」で検索したときに「FBI」だけでなく「Facebook」も表示したいと思いました。
そのために「FBI」と「Facebook」の両方の「discription」に、「FBI,Facebook」と入力しておき、その「discription」を検索対象にすれば片方の入力で両方表示できて利便性がアップできるのでは?と考えた感じです。
回答4件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/06/18 01:48 編集