如何在自定义函数中使用 wordpress 函数? [英] how to used wordpress function inside the custom function?
本文介绍了如何在自定义函数中使用 wordpress 函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<?php function tms_footerWidget(){
global $wpdb;
$results = $wpdb->get_results( "SELECT `tms_footerColumns` FROM `wp_tms`");
foreach ($results as $row) {
$tms_footerWidget = $row->tms_footerColumns;
}
$colsOne="<div class=\"col-xs-12 col-md-12 col-sm-12\"><div class=\"thumbnail\"><?php dynamic_sidebar('tms_footer2'); ?></div>";
return $colsOne;
}
?>
并且在我在我的 html 代码中使用了这个函数并且当时我运行了我的 php 页面之后,这些函数无法工作..所以我在检查元素中看到了错误类型请告诉我这个问题的答案问题...
and after i have used this function in my html code and i run my php page at that that time these function could not working ..so i see in inspect elements following type of the error plz..tell me answer of this problem...
推荐答案
你必须在使用自定义函数时传递 wordpress hook.(即,add_action('wp_head', 'tms_footerWidget'))
You haveto pass wordpress hook as you are using custom function. (i.e., add_action('wp_head', 'tms_footerWidget'))
这篇关于如何在自定义函数中使用 wordpress 函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文