wordpress functions.php
I'm having issues with the functions.php file with variables
$prev_dept = 0;
$comment_count = 0;
$comment_index = 0;
functio开发者_C百科n setCommentCount($size){
$comment_count = $size;
}
function flowhub_comment($comment, $args, $depth) {
$comment_index ++;
if($depth > 1) {
$line = true;
}
echo '$prev_dept:' . $prev_dept.'<br>';
}
I can't access $comment_index so I can't set nor get it from within a function. What should I do to fix this?
Yours truthfully
$comment_index
is not within the scope of the functions, you need to use global
. More details on scoping in PHP.
The way functions.php works is not just a plain include, try GLOBAL it might help.
function setCommentCount($size){
global $comment_count;
$comment_count = $size;
}
精彩评论