简体   繁体   English

Wordpress全局变量在功能上不起作用

[英]Wordpress global vars no works in function

I have 2 global vars defined inside funtions.php , the value of this vars to take from include file : 我在funtions.php内定义了2个全局变量,该变量的值来自包含文件:

global $ruta_path;
global $ruta_db;

I want send the value of this global values to function in comments but no get works 我想发送此全局值的值以在注释中起作用,但无法正常工作

Inside comments.php i have this function - no put all content here: 在comments.php内部,我具有此功能-不在此处放置所有内容:

<?php 

global $ruta_path;
global $ruta_db;


function p_comment( $comment, $args, $depth )
{

global $ruta_path;
global $ruta_db;

/// to take value of global vars global $ruta_path; global $ruta_db;

} 

?>

Also under of this i can see the structure of divs for comments and inside i have this : 此外,在此下,我可以看到div的结构以进行注释,而在我的内部有:

<?php wp_list_comments( array( 'callback' => 'p_comment' ) ); ?>

The case i´m turn crazy with this because i try all and no send the values of global vars i need this for work but no get i try with $GLOBALS and continue no working , how i can use this global vars and send to function and when callback call function for these comments because i try all and no get the function and call back take the values 这种情况让我发疯了,因为我尝试了所有并且没有发送全局变量的值,我需要它来工作,但是没有得到,我尝试使用$ GLOBALS并继续不起作用,如何使用此全局变量并发送给函数以及当这些评论的回调调用函数时,因为我尝试了所有但没有得到该函数并回叫取值

Thank´s !!! 谢谢 !!!

You would be better set to create your globals and function definition within the functions.php file, for more info on the purpose of this file refer to the documentation . 您最好设置为在functions.php文件中创建全局变量和函数定义, 有关此文件用途的更多信息, 请参考文档 If you are defining the global vars and function only within the comments.php you risk issue with the callback not firing against a registered function within the global space. 如果仅在comments.php中定义全局变量和函数,则可能会出现回调不针对全局空间内的已注册函数触发的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM