Wordpress定制:post—;发布在()上的功能twentyten的日期/时间

Wordpress定制:post—;发布在()上的功能twentyten的日期/时间,wordpress,datetime,time,date,customization,Wordpress,Datetime,Time,Date,Customization,大家好。我最近开始调整新的默认wp主题,二十十。当我意识到loop()函数调用twentyten_posted_on()时,我正在改变发布日期和时间的显示方式;显示所述信息的位置。所以我最终在functions.php中找到了这个函数。到现在为止,一直都还不错。下面是它的样子: function twentyten_posted_on() { printf( __( '<span class="%1$s">Posted on</span> %2$s <span cl

大家好。我最近开始调整新的默认wp主题,二十十。当我意识到loop()函数调用twentyten_posted_on()时,我正在改变发布日期和时间的显示方式;显示所述信息的位置。所以我最终在functions.php中找到了这个函数。到现在为止,一直都还不错。下面是它的样子:

function twentyten_posted_on() {
printf( __( '<span class="%1$s">Posted on</span> %2$s <span class="meta-sep">by</span> %3$s', 'twentyten' ),
    'meta-prep meta-prep-author',
    sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a>',
        get_permalink(),
        esc_attr( get_the_time() ),
        get_the_date()
    ),
    sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
        get_author_posts_url( get_the_author_meta( 'ID' ) ),
        sprintf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ),
        get_the_author()
    )
);
我需要能够做到上述,以便我可以适当地格式化我的日期信息,并有网站的外观正是我想要的方式

要获得良好的参考:

  • 以下是静态html+css页面:
  • 这是我的测试页面 将静态转换为完全静态 功能正常的wordpress网站:
提前谢谢 G.Campos

在sprintf中使用的符号是“%3$s”。“%3”表示将第三个变量参数(get_the_date())用作字符串($s)

因此,您可以通过如下更改twentyten_post_on函数将原始跨度拆分为三个div:

<div class="day">$dayvar</div>
<div class="month">$monthvar</div>
<div class="year">$yearvar</div>
function twentyten_posted_on() {
printf( __( '<span class="%1$s">Posted on</span> %2$s <span class="meta-sep">by</span> %3$s', 'twentyten' ),
    'meta-prep meta-prep-author',
    sprintf( '<a href="%1$s" title="%2$s" rel="bookmark">
            <div class="day">%3$s</div>
            <div class="month">%4$s</div>
            <div class="year">%5$s</div>
        </a>',
        get_permalink(),
        esc_attr( get_the_time() ),
        date("d", strtotime(get_the_date())), 
        date("m", strtotime(get_the_date())), 
        date("Y", strtotime(get_the_date())), 
    ),
    sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
        get_author_posts_url( get_the_author_meta( 'ID' ) ),
        sprintf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ),
        get_the_author()
    )
);
函数twentyten发布在()上{
printf(uuuu('3$s'在%2$s上发布,'twentyten'),
“元准备元准备作者”,
sprintf(“”,
get_permalink(),
esc_attr(获取时间()),
日期(“d”,strotime(获取日期()),
日期(“m”,标准时间(获取日期()),
日期(“Y”,strottime(获取日期()),
),
sprintf(“”,
获取作者帖子url(获取作者元数据('ID'),
sprintf(esc_attr_uuuuu('按%s查看所有帖子','twentyten'),获取作者(),
找到作者()
)
);
或者您可以进入get_the_date函数并将其更改为将日期作为3个div返回