【问题标题】:wordpress updating deprecated get_the_author functionwordpress 更新不推荐使用的 get_the_author 函数
【发布时间】:2011-08-24 02:00:41
【问题描述】:

我正在更新旧主题并收到此消息。

注意:调用 get_the_author 时使用的参数自 2.1 版起已弃用,没有其他可用的替代方法。在第 3468 行的 /srv/www/virtual/example.com/htdocs/zzblog/wp-includes/functions.php 首页 pageid-641 page-author-test page-template page-template-MIMindexMOD-php">

我可以在我的主题functions.php中找到调用如下:

c[] = 'page-author-' . sanitize_title_with_dashes(strtolower(get_the_author('login')));

这是我能找到的对 get_the_author 的唯一参考。在 wordpress 法典中,它说整个函数 get_the_author 已贬值(连同传递的参数),因此想更新但不确定如何更新。

【问题讨论】:

    标签: wordpress themes


    【解决方案1】:

    只需替换行:

    c[] = 'page-author-' . sanitize_title_with_dashes(strtolower(get_the_author('login')));
    

    通过这个:

    c[] = 'page-author-' . sanitize_title_with_dashes(strtolower(get_the_author()));
    

    http://codex.wordpress.org/Function_Reference/get_the_author 中出现的函数没有被弃用,只是参数被弃用,因为现在函数总是返回用户显示名称,所以不需要指定所需的返回值是用户“登录”。

    【讨论】:

      猜你喜欢
      • 2022-10-20
      • 2019-05-13
      • 2012-11-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多