2017-02-23 62 views
0
单数页

我试图让下一个/上一个链接在我的单身后的网页上,那将链接到下一篇文章在同一类别中的自定义帖子类型。显示下一页/上一页链接到同一分类下发布指定的投递类型

cpt_exhibit < - 自定义后类型

这是我到目前为止有:

if (is_singular('cpt_exhibit')) : 

    $terms = get_the_terms($postid, 'ctax_exhibit_category'); 
    $t_name = $terms[0]->slug; 

    previous_post_link('%link', 'Previous in category', true, $t_name); 
endif; 

这是我的$terms

array(1) { 
    [0]=> 
    object(WP_Term)#2321 (10) { 
     ["term_id"]=> 
     int(12) 
     ["name"]=> 
     string(9) "Tank Park" 
     ["slug"]=> 
     string(9) "tank-park" 
     ["term_group"]=> 
     int(0) 
     ["term_taxonomy_id"]=> 
     int(12) 
     ["taxonomy"]=> 
     string(21) "ctax_exhibit_category" 
     ["description"]=> 
     string(0) "" 
     ["parent"]=> 
     int(0) 
     ["count"]=> 
     int(15) 
     ["filter"]=> 
     string(3) "raw" 
    } 
} 

vardump现在$ t_name吐出蛞蝓,其内cpt_exhibit的活动类型相匹配,但是我觉得我失去了一些东西。这不会输出任何内容。我试图改变ctax_exhibit_category到自定义后的类型,但后来我得到一个错误无效的分类。

我没有打造出来的自定义文章类型,我只是做一个客户端请求的更新。

如果有人能帮助我,那太棒了,谢谢!

回答

1

previous_post_link不需要塞。你将slug传递给期待excluded_terms的函数。

相信它应该是这个样子:

previous_post_link('%link', 'Previous in category', true, '', ctax_exhibit_category);

该文档还cover this briefly

+0

你,先生,是真棒。非常感谢你帮助我!编辑:我注意到的一件事是,在该分类中有一个类别的帖子,比如说'tank-park',它只会循环2或3个帖子,然后将其称为结束,尽管该类别有10个帖子。有任何想法吗? – Ishio

+0

似乎问题已解决,这是由于帖子被导入的方式,所有这些都没有适当的时间戳,导致它们显示为同时发布 – Ishio

相关问题