在类别中。php模板,我构建了一个函数,在主循环之前列出“特色”帖子。使用自定义字段和get\\u posts()选择特色帖子:
function list_featured_articles(){
$featured_posts = get_posts(\'meta_key=featured_article&meta_value=on&numberposts=10&order=DESC&orderby=post_date\');
}
我的类别。php模板:echo list_featured_articles();
get_template_part( \'loop\', \'category\' );
它工作得很好,只是特色文章也列在文章的类别列表中。我想,从我的功能中,获取特色帖子的ID,并将其从主循环中删除。有没有合适的方法?我想我可以使用一个全局变量来存储排除ID的数组,但我希望避免使用全局变量。