Wp_get_recent_posts与附加的帖子不正确工作


wp_get_recent_posts not working correctly with appended posts

我想把一些帖子附加到wp_get_recent_posts函数,所以它们总是用正常的结果检索,问题是我没有得到我想在结果中附加的帖子,我做错了吗?

$include = array(1, 2);
$args = array(
        'showposts' => 10, 
        'tag_id' => '123',
        'post_status' => 'publish',
        'exclude' => $current_id,
        'orderby' => 'post_date',
        'append' => $include,
    );
    $entries = wp_get_recent_posts($args, 'ARRAY_A');

如果我删除tag_id参数,那么我想要附加的帖子都包含在结果中,但我需要通过标签ID过滤正常结果,似乎WP也过滤附加的帖子与其他参数,是否有任何解决方案?

根据https://codex.wordpress.org/Function_Reference/wp_get_recent_posts没有'append'参数,但有一个'include'参数做你想要的。

Try this:

$args = array(
    'showposts' => 10, 
    'tag_id' => '123',
    'post_status' => 'publish',
    'exclude' => $current_id,
    'orderby' => 'post_date',
    'include' => $include,
);