I am trying to use WordPress functions on a custom file but doesn't seems to be working. The file is placed in root directory. Please help me out
3条回答
- douciwang6819 2018-11-13 15:28关注
In any custom page you can call below three lines to pull up WordPress stack and then use any WordPress functionality
<? //Imp to include include('wp-load.php'); define('WP_USE_THEMES', false); require('wp-blog-header.php'); // check is user is logged - if yes then print its role if(is_user_logged_in() ) { $user = wp_get_current_user(); $role = ( array ) $user->roles; echo "role is ".$role[0]; } ?>
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 delta降尺度计算的一些细节,有偿
- ¥15 Arduino红外遥控代码有问题
- ¥15 数值计算离散正交多项式
- ¥30 数值计算均差系数编程
- ¥15 redis-full-check比较 两个集群的数据出错
- ¥15 Matlab编程问题
- ¥15 训练的多模态特征融合模型准确度很低怎么办
- ¥15 kylin启动报错log4j类冲突
- ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
- ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序