我在主题functions.php文件中创建了一些函数, 并在header.php文件中调用了main函数, 并将结果存储到变量中, 我想在小部件中使用此值。
可能吗 ?
#1
你有尝试过吗?
http://wordpress.org/extend/plugins/php-code-widget/
还有其他的插件也可以做同样的事情:允许在文本小部件中执行PHP。
#2
你可以将变量(例如主题选项)保存在wp_options表中。
要添加设置值, 请使用update_option(), 并使用get_option读取该值。
还可以使用add_option(), 但仅当数据库中不存在该变量时, 它才有效。因此, 首选update_option()。
#3
在小部件中获取变量只需使用:
$variable=$GLOBALS['theme_variable'];
来源:
https://www.srcmini02.com/66166.html
微信公众号
手机浏览(小程序)
Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(): Failed to enable crypto in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_37130.jpg): failed to open stream: operation failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57