wordpress函数,PHP不处理,显示为纯文本 请使用“wp\u get\u current\u user()”函数,因为“get\u currentuserinfo()”函数已被弃用,所以您要在何处添加此php代码?(我相信divi的共同点是有一个子

wordpress函数,PHP不处理,显示为纯文本 请使用“wp\u get\u current\u user()”函数,因为“get\u currentuserinfo()”函数已被弃用,所以您要在何处添加此php代码?(我相信divi的共同点是有一个子,php,wordpress,Php,Wordpress,wordpress函数,PHP不处理,显示为纯文本 请使用“wp\u get\u current\u user()”函数,因为“get\u currentuserinfo()”函数已被弃用,所以您要在何处添加此php代码?(我相信divi的共同点是有一个子主题,只需将自定义代码填充到functions.php中即可。)如果您的php没有在html/php文件中处理,这是一个web服务器问题,但如果您试图将其添加到构建器中的某个块中,则我不希望它能工作。您可以在functions.php中创建一个

wordpress函数,PHP不处理,显示为纯文本
请使用“wp\u get\u current\u user()”函数,因为“get\u currentuserinfo()”函数已被弃用,所以您要在何处添加此php代码?(我相信divi的共同点是有一个子主题,只需将自定义代码填充到functions.php中即可。)如果您的php没有在html/php文件中处理,这是一个web服务器问题,但如果您试图将其添加到构建器中的某个块中,则我不希望它能工作。您可以在functions.php中创建一个短代码,然后从builder.On页面上使用该代码进行测试。创建新页面,将代码粘贴到文本框、代码框以及纯wordpress文本编辑器选项卡中。不处理代码。是的,除非你添加一些可怕的RunAnywhere插件或类似的插件,否则这是行不通的。如果是特定页面的代码,我会创建一个新的
页面-{id或slug}.php
。ie:
page fun.php
通过复制现有的page.php。然后在那里添加代码。如果是更一般的代码,我会使用functions.php。确保您可以直接访问这些文件,或者如果代码出错,您可以将自己锁定在外。从文本框运行代码的另一个选项是短代码。但是您仍然需要将短代码添加到functions.php,然后使用短代码从内容中调用它。如果您可以从文本框中运行任意php,那么破坏任何wordpress站点都太容易了。即使不假设wordpress的普通用户不知道php。
     <?php
global $current_user;
get_currentuserinfo();

printf( __( 'Username: %s', 'textdomain' ), esc_html( $current_user->user_login ) ) . '<br />';
printf( __( 'User email: %s', 'textdomain' ), esc_html( $current_user->user_email ) ) . '<br />';
printf( __( 'User first name: %s', 'textdomain' ), esc_html( $current_user->user_firstname ) ) . '<br />';
printf( __( 'User last name: %s', 'textdomain' ), esc_html( $current_user->user_lastname ) ) . '<br />';
printf( __( 'User display name: %s', 'textdomain' ), esc_html( $current_user->display_name ) ) . '<br />';
printf( __( 'User ID: %s', 'textdomain' ), esc_html( $current_user->ID ) );