自带sitemap功能详解如何加上最后更新时间?

默认sitemap xml里面只有地址,并没有更新时间:

只有地址
只有地址

如何加入时间?在functions.php中加入:

add_filter(
    'wp_sitemaps_posts_entry',
    function( $entry, $post ) {
        $entry['lastmod'] = $post->post_modified_gmt;
        return $entry;
    },
    10,
    2
);
带有时间
带有时间

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注