[英]Multiple str_replace Not Working
I can seen to get this working in my functions.php file on wordpress. 我可以在Wordpress上的functions.php文件中看到此功能。
Heres my code: 这是我的代码:
add_filter( 'mycred_ranking_row', 'my_custom_ranking_rows', 10, 4 );
function my_custom_ranking_rows( $layout, $template, $row, $position )
{
return str_replace( '%avatar%', get_avatar( $row['ID'], 32 ), $layout );
}
add_filter( 'mycred_ranking_row', 'my_custom_ranking_rows', 10, 4 );
function my_custom_ranking_rows( $layout, $template, $user, $position )
{
$rank = mycred_get_users_rank( $user['ID'] );
return str_replace( '%level%', $rank, $layout );
}
as you can see i have two different add_filter functions. 如您所见,我有两个不同的add_filter函数。 If i have any one of them on their own it works fine.
如果我自己拥有其中任何一个,则效果很好。 But when i have both i get a error.
但是当我两个都遇到错误时。 Help!
救命!
You defined the function my_custom_ranking_rows()
twice. 您两次定义了函数
my_custom_ranking_rows()
。 Try using different function names. 尝试使用其他函数名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.