我正在使用显示列表或档案
<?php get_archives(\'monthly\', \'\', \'html\', \'\', \'\', FALSE); ?>
并显示我的列表2012年12月-2012年11月等
但是,我想将其格式化以显示:
12.1211.1210.12等
有什么想法吗?
我正在使用显示列表或档案
<?php get_archives(\'monthly\', \'\', \'html\', \'\', \'\', FALSE); ?>
并显示我的列表2012年12月-2012年11月等
但是,我想将其格式化以显示:
12.1211.1210.12等
有什么想法吗?
但过滤器很糟糕,它只提供HTML链接:
add_filter( \'get_archives_link\', \'wpse74891_archives_link\' );
function wpse74891_archives_link( $link ) {
$link = preg_replace_callback( \'/>([A-Za-z]+\\s+\\d{4})/\', function( $matches ) {
return \'>\' . date( \'m.y\', strtotime( $matches[1] ) );
}, $link );
return $link;
}
使用此方法,您至少可以为链接传递任何想要的日期格式。我正在使用此自定义功能为用户在我的网站前端添加发布/取消发布按钮: if (\'draft\' == get_post_status ($post_id)) { $post = get_post($post_id,ARRAY_A); $post[\'post_status\'] =\'publish\'; wp_insert_post($post); }