###質問内容・get_adjacent_postについて
wordpressのsingle.phpの記事ページのページング(ページネーション)で疑問があります。
関数get_adjacent_post
なんですが、
php
1get_adjacent_post( $in_same_term, $excluded_terms, $previous, $taxonomy )
引数の$excluded_terms
はページングの際に除外したいタームIDを入れることができます。
この$excluded_terms
を除外ではなく、当てはまるタームIDを入れるようにしたいのです。
###試みたこと
ソースファイルであるwp-includes/link-template.php
からget_adjacent_post
を編集を試みました。
以下の文が関係すると思いました。
php
1// Remove any exclusions from the term array to include. 2 $term_array = array_diff( $term_array, (array) $excluded_terms ); 3 $term_array = array_map( 'intval', $term_array ); 4 5 if ( ! $term_array || is_wp_error( $term_array ) ) 6 return ''; 7 8 $where .= " AND tt.term_id IN (" . implode( ',', $term_array ) . ")";
array_diff
をarray_intersect
に変更してみたが、ページングのリンクは反応してくれませんでした。(次のページのurlを持ってこれなかった)
###やりたいこと
get_adjacent_post
の引数の$excluded_terms
で
除外したいタームIDを入力するのではなく、
当てはまるタームIDを入力するようにしたいです。
除外ではなく、当てはまるものという風に変えたいです。
この問題を解決できる、解決法を知っていればご教授いただきたいです。
よろしくお願いいたします。
回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/01/17 04:28