编辑:我打开了一个新的问题,因为我看到我需要一个php代码,而不是jquery : Add echo to my wordpress sidebar for non-connected users。
在我的WordPress测试网站中,我使用进行连接。不幸的是,登录小部件没有“铭文”链接,所以我在登录小部件下面的文本小部件中创建了一个链接。问题是,这个链接不是与登录小部件同步的,它甚至在成员连接和联机时也是可见的。我想让“铭文”链接不可见,当有人连接。
我使用在我的情况下不起作用的jQuery,因为当登录小部件刷新页面时,jQuery效果没有保留,但是css获得了优先级.请参阅这里的演示:http://www.igorlaszlo.com/test/ -您可以使用用户名: testing / password : testing2014连接自己
CSS
/* this is the text widget with the "Inscription" link */
#text-7 {
opacity: 1;
}
脚本
// when the "Login" button is loaded and clicked, Inscription link is invisible
jQuery('.sp-widget-login-div form p input').load(function(){
jQuery('#text-7').animate({'opacity':0},500,'easeInCirc');
});
jQuery('.sp-widget-login-div form p input').click(function(){
jQuery('#text-7').animate({'opacity':0},500,'easeInCirc');
});
// when the "Logout" link is loaded and clicked, Inscription link is visible
jQuery('.logout-link').load(function(){
jQuery('#text-7').animate({'opacity':1},500,'easeInCirc');
});
jQuery('.logout-link').click(function(){
jQuery('#text-7').animate({'opacity':1},500,'easeInCirc');
});
谢谢你提前帮忙!
发布于 2014-10-12 15:20:19
使用is_user_logged_in()函数显示或隐藏链接。
if ( is_user_logged_in() ) {
echo '<a href="#">Your link</a>';
}
https://stackoverflow.com/questions/26326401
复制相似问题