只需更改订单参数DESC
到ASC
:
function Get_First_permalink(){
global $post;
$tmp_post = $post;
$args = array(
\'numberposts\' => 1,
\'offset\' => 0,
\'orderby\' => \'post_date\',
\'order\' => \'ASC\',
\'post_type\' => \'POST_TYPE_NAME\',
\'post_status\' => \'publish\' );
$myposts = get_posts( $args );
setup_postdata($myposts[0]);
$permalink = get_permalink($post->ID);
$post = $tmp_post;
return $permalink;
}
因此,一旦您将该函数粘贴到主题函数中。php和您已更改
POST_TYPE_NAME
对于您的帖子类型名称,您可以随时调用它:
<a href="<?php echo Get_First_permalink(); ?>">First Post</a>