【问题标题】:Wordpress: output post title in lowercase?Wordpress:以小写形式输出帖子标题?
【发布时间】:2021-09-14 21:47:51
【问题描述】:

我在我的 wordpress 主题的 loop_single.php 中乱七八糟地以小写形式输出帖子标题。

我的内容有 non-ascii 字符,所以我认为以下内容会起作用:

<?php echo mb_strtolower(the_title()); ?>

但它不起作用。它只是按照它的书写方式输出标题。

【问题讨论】:

    标签: php css wordpress wordpress-theming custom-wordpress-pages


    【解决方案1】:

    只使用 CSS 怎么样?

    h1.post-title { /* or whatever the selector is */
        text-transform: lowercase;
    }
    

    https://developer.mozilla.org/en/CSS/text-transform#Values

    【讨论】:

    • +1 这更适合搜索引擎、禁用 CSS 的人和 Lynx 用户。 :)
    【解决方案2】:

    你试过了吗

    <?php echo mb_strtolower(the_title(),'UTF-8'); ?>
    

    【讨论】:

      【解决方案3】:

      如果将来有人出于非 CSS 相关的原因尝试这样做,此链接将非常有帮助。

      https://wordpress.stackexchange.com/questions/39145/how-do-i-convert-a-pages-title-to-lower-case

      get_the_title($post->ID);优于 the_title();在这种情况下。

      【讨论】:

        猜你喜欢
        • 2018-02-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-01-10
        • 1970-01-01
        • 1970-01-01
        • 2010-12-04
        • 1970-01-01
        相关资源
        最近更新 更多