2016-07-08 2 views
0

** 업데이트 (조금 걸림이 있음) ...사용자 지정 분류법을 페이지 탐색으로 사용

분류학 용어를 반향하여 코드를 작동 시켰습니다. 작은 걸림돌이 하나 있습니다. 하나 이상의 용어를 선택할 수 없습니다. 그렇지 않으면 무엇을해야할지 모릅니다. 여기에 코드가 있습니다. 에코 준비

가져 기간 :

<?php $my_terms = get_the_terms($post->ID, 'YOUR_TERM_HERE'); 
if($my_terms && !is_wp_error($my_terms)) { 
    foreach($my_terms as $term) {} 
} ;?> 

설정 페이지 탐색 :

<?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>'; 
        } ;?> 

사람이 하나 개 이상의 분류 용어로이 작업을 수행하는 방법을 알고있는 경우. 나는 정말로 알고 싶다.

음, 이것은 아마도 설명하기 어려운 것이지만 최선을 다할 것입니다.

사용자 정의 게시 유형 about us이 있고 해당 CPT에 계층 별 사용자 정의 분류 our team이 생성되었습니다. 그 맞춤식 분류에 몇 가지 항목을 추가했습니다.

  • 팀 부재 (1)
  • 팀 부재 (2)
  • 등 내가 뭘하려고 오전 (DIV) 즉 표시하면 필드가있을 것 팀 부재 (1)을 클릭 할 때입니다

팀원 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'); ?> 

비슷한 뭔가를하거나 시작하는 위치를 알고있다 사람이 있습니까 ...

답변

0

사용이

<?php previous_post_link('<div class="prev">%link</div>'); ?> <?php next_post_link('<div class="next">%link</div>'); ?>

에게 %link은 다음 팀원의 이름을 표시합니다

+0

감사합니다. 그러나 이는 맞춤 분류에 적합하지 않습니다. 그냥 다음 게시물로 이동하고 사용자 지정 분류를 필터링하지 않습니다. – Steggie

0

알고 싶으신 분을 위해 OP로 업데이트하십시오.

관련 문제