简体   繁体   中英

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 :

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:

<?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 :

<?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

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 . 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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