Wordpress自定义帖子类型分页,只显示那些自定义字段选中


Wordpress custom post type pagination to only show those with custom field checked

我在过去的一天左右一直在试图弄清楚这个问题,但我还是遇到了问题!

我有一个自定义的帖子类型叫做案例研究。在案例研究中有一个名为"featured_case_study"的自定义字段,它是一个真/假字段。如果用户选中了这个方框,它将使案例研究成为"特色"。

一旦我进入一个有特色的案例研究文章,我想使用分页移动到下一个有特色的案例研究。目前我的分页包括我所有的案例研究,但我只希望它分页之间的特色。

我已经尝试了各种不同的方法,但我似乎无法找到这个。有人以前遇到过这个吗?

你必须首先找出你的分页代码在哪里(取决于你正在使用的插件),然后:

$pageID = get_the_ID(); //get the post ID of the current post
if (the_field("featured_case_study", $pageID) == "true")
{
// then the same code as the rest of the pagination, copy it in!
//Only, when it comes to next and previous, you must emphasis AGAIN that
if (the_field("featured_case_study", $NextPageID) == "true")
//then have it linked as next
if (the_field("featured_case_study", $PreviousPageID) == "true")
//then have it linked as previous
}