dsdioa9545 2010-08-30 17:55
浏览 57
已采纳

如何在Wordpress日期函数中为月份和年份的样式提供单独的类?

I'm in wordpress, trying to format the date output. This is the code I'm using at present:

<div class="date"><?php the_date('M, Y'); ?></div>

It's output looks like this:

MAY, 2010

What I want to do is have the date display like this (The month on top of the year):

MAY

2010

I'm just not familiar enough with PHP to get things working. A simple line break wouldn't quite be sufficient because I want to play with sizing, placement of each separately (month text larger than the year text, both centered, etc.). Separate classes applied to each would be ideal.

  • 写回答

6条回答 默认 最新

  • duansen6750 2010-09-02 05:08
    关注
    <div class="date">
      <span class='month'><?php the_date('M');?></span>
      <span class='year'><?php the_date('Y'); ?></span>
    </div>
    

    You can then set the spans to display: block if you want them to each be on their own line:

    <style type='text/css'>
      .date span { display: block ; } 
    </style>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀