
先判断下是否登录,然后获取当前用户对象,然后获取当前用户对象的信息,需要哪些用哪些:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
if(is_user_logged_in()){
$current_user = wp_get_current_user();
/
@example Safe usage: $current_user = wp_get_current_user();
if ( !($current_user instanceof WP_User) )
return;
/
echo 'Username: ' $current_user->user_login '<br />';
echo 'User email: ' $current_user->user_email '<br />';
echo 'User first name: ' $current_user->user_firstname '<br />';
echo 'User last name: ' $current_user->user_lastname '<br />';
echo 'User display name: ' $current_user->display_name '<br />';
echo 'User ID: ' $current_user->ID '<br />';
}
你是指的html中的title属性,打开主题中的headerphp,修改成这句
<title><php bloginfo('name'); if(is_home() || is_front_page()) { echo ' - '; bloginfo('description'); } else { wp_title(); } ></title>
这个截取函数不支持中文,所以会出现乱码,给个正确的给你
将下面的代码添加到主题的 functionsphp 文件:
function customTitle($limit) {
$title = get_the_title($post->ID);
if(strlen($title) > $limit) {
$title = substr($title, 0, $limit) '';
}
echo $title;
}
然后在输出文章标题的地方,使用代码:<php customTitle(30); >
以上就是关于怎么去掉wordpress页面标题中的网站标题全部的内容,包括:怎么去掉wordpress页面标题中的网站标题、用wordpress 怎么把栏目标题显示在网站名那里、wordpress文章标题截取问题等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)