**更新(ちょっとした不具合を含む)...カスタム分類法をページナビゲーションとして使用する
分類法の用語をエコーしてコードを取得しました。ちょっとしたものがあります。 1つ以上の用語を選択することはできません。それ以外は何をすべきか分からない。ここにコードがあります。誰かが複数の分類用語でこれを行う方法を知っている場合は
<?php // get_posts in same custom taxonomy
$postlist_args = array(
'posts_per_page' => -1,
'orderby' => '',
'order' => 'ASC',
'post_type' => 'YOUR_POST_TYPE_HERE',
'YOUR_TERM_HERE' => array($term->slug) // here is your echo
);
$postlist = get_posts($postlist_args);
// get ids of posts retrieved from get_posts
$ids = array();
foreach ($postlist as $thepost) {
$ids[] = $thepost->ID;
}
// get and echo previous and next post in the same taxonomy
$thisindex = array_search($post->ID, $ids);
$previd = $ids[$thisindex-1];
$nextid = $ids[$thisindex+1];
if (!empty($nextid)) {
echo '<a rel="next" href="' . get_permalink($nextid). '"><i class="fa fa-chevron-circle-left" aria-hidden="true"></i></a>';
}
if (!empty($previd)) {
echo '<a rel="prev" href="' . get_permalink($previd). '"><i class="fa fa-chevron-circle-right" aria-hidden="true"></i></a>';
} ;?>
:
<?php $my_terms = get_the_terms($post->ID, 'YOUR_TERM_HERE');
if($my_terms && !is_wp_error($my_terms)) {
foreach($my_terms as $term) {}
} ;?>
セットアップあなたのページナビゲーション:
は、エコーのための準備期間を取得します。私は本当に知りたいです。
これはおそらく説明するのが難しいかもしれませんが、私は最善を尽くします。
私はカスタムポストタイプabout us
を得て、そのCPTでは階層カスタム分類タイルour team
を作成しました。私はそのカスタムタクソノミーにいくつかの項目を追加しました。私がやろうとしています何
- チームのメンバー1
- チームのメンバー2
- など
あなたはチームのメンバー1をクリックしたときに表示されるフィールド(DIV)があるでしょうですチームメンバー2の名前をクリックすると、次のチームメンバーに行くことができます。
それBU何かが、それはpost_typeトラフ行くカスタム分類スルー行かないんのこの種:
<?php // get_posts in same custom taxonomy
$postlist_args = array(
'posts_per_page' => -1,
'orderby' => 'menu_order title',
'order' => 'ASC',
'post_type' => 'over-ons',
'taxonomy' => 'ons_team'
);
$postlist = get_posts($postlist_args);
// get ids of posts retrieved from get_posts
$ids = array();
foreach ($postlist as $thepost) {
$ids[] = $thepost->ID;
}
// get and echo previous and next post in the same taxonomy
$thisindex = array_search($post->ID, $ids);
$previd = $ids[$thisindex-1];
$nextid = $ids[$thisindex+1];
if (!empty($previd)) {
echo '<a rel="prev" href="' . get_permalink($previd). '">previous</a>';
}
if (!empty($nextid)) {
echo '<a rel="next" href="' . get_permalink($nextid). '">next</a>';
} ;?>
オリジナルのコードが書かれています:
// get_posts in same custom taxonomy
$postlist_args = array(
'posts_per_page' => -1,
'orderby' => 'menu_order title',
'order' => 'ASC',
'post_type' => 'your_custom_post_type',
'your_custom_taxonomy' => 'your_custom_taxonomy_term'
);
$postlist = get_posts($postlist_args);
// get ids of posts retrieved from get_posts
$ids = array();
foreach ($postlist as $thepost) {
$ids[] = $thepost->ID;
}
// get and echo previous and next post in the same taxonomy
$thisindex = array_search($post->ID, $ids);
$previd = $ids[$thisindex-1];
$nextid = $ids[$thisindex+1];
if (!empty($previd)) {
echo '<a rel="prev" href="' . get_permalink($previd). '">previous</a>';
}
if (!empty($nextid)) {
echo '<a rel="next" href="' . get_permalink($nextid). '">next</a>';
}
私your_custom_taxonomy_term
何ですが?私は自分の分類法のために持っているとは思わないので?
通常のナビゲーションは動作しません:
<?php posts_nav_link('separator','prelabel','nextlabel'); ?>
は似たものを作ったりどこから始めれば知っている誰もが
ありがとうございます。しかし、それはカスタムタクソノミーでは機能しません。それはちょうど次の投稿に行き、カスタムタクソノミーをファイリングしません。 – Steggie