Php 我如何才能得到当前类别的第一篇帖子并回复链接?

Php 我如何才能得到当前类别的第一篇帖子并回复链接?,php,wordpress,Php,Wordpress,我试图创建一个代码,从一个类别中检索第一篇文章并回显链接 但是,代码总是与当前帖子保持永久链接。有人能帮我修一下吗 <?php global $post; $category = get_the_category($post->ID); $category = $category[0]->cat_ID; $array = new WP_Query(array( 'category__in' => ar

我试图创建一个代码,从一个类别中检索第一篇文章并回显链接

但是,代码总是与当前帖子保持永久链接。有人能帮我修一下吗

    <?php
    global $post;
    $category = get_the_category($post->ID);
    $category = $category[0]->cat_ID;
        $array = new WP_Query(array(
            'category__in' => array($category),
            'post_per_page' => 1,
            'order' => 'asc',
            'orderby' => 'id'

    ));?>
    <?php the_permalink($post->ID); ?>


您根本没有使用您的查询。哦,是这样吗?我仍然对数组和wp_查询感到困惑,你能帮我吗?哦,我现在明白了,谢谢@Stender it working:)酷-我正要为你写它-但很高兴你得到了它。
$args = array(
            'numberposts' => 1, 
             'orderby' => 'post_date',
            'order' => 'ASC', 
            'fields'          => 'ids',
            'category' => 8 //or use further logic to check in list
        );
     $post_cus = get_posts($args);
     $first_post_id = $post_cus[0];
     $post_url = get_the_permalink ($first_post_id);