更改php代码以符合我的要求

时间:2018-07-18 14:08:46

标签: php wordpress

我有这行需要替换/编辑以适合我的需求。这段代码是从wordpress数据库中提取名字和姓氏:

'<strong>' . get_the_author_meta( 'display_name', $freelancer ) . '</strong>',

我需要在网站上仅显示名字和姓氏的首字母。

我在其他情况下使用了波纹管代码,并且工作正常,但我不知道如何使它适应上述代码:

<?php
$first_name = get_the_author_meta( 'first_name', $freelancer );
 $last_name = substr( get_the_author_meta( 'last_name', $freelancer ), 0, 1 ) . '.';
$display_name = $first_name . ' ' . $last_name;
echo $display_name;
?>

所以我的第二个代码运行良好,但是我需要用适当的代码替换第一个代码才能获得相同的结果,但我不知道如何,无论如何,这是我需要更改的更多上下文代码:

$message = sprintf( __( '%s cancelled his project %s', ET_DOMAIN ),
                '<strong>' . get_the_author_meta( 'first_name', $freelancer ) . '</strong>',
                '<strong>' . get_the_title( $project ) . '</strong>'
            );

0 个答案:

没有答案
相关问题