doujiang1913 2017-12-05 16:32
浏览 68
已采纳

将占位符文本添加到Wordpress wp-login.php页面

So I want to add placeholder text to the Username and Password fields on the standard wp-login.php page - I don't want to edit the actual wp-login.php page because every time WordPress is updated my amends will just be wiped.

So! In functions.php I've added a simple function to add a .js file (and some css files but I don't think that's important for this) to the wp-login.php page where I have this code - here is my function in functions.php

function my_custom_login() {
  echo '<link rel="stylesheet" type="text/css" href="/shared-assets/css/main-screen-styles.css" />';
  echo '<link rel="stylesheet" type="text/css" href="' . get_bloginfo('stylesheet_directory') . '/css/campsite-finder-screen-styles.css" />';
  echo '<script type="text/javascript" href="/shared-assets/js/test.js">
</script>';
}
add_action('login_head', 'my_custom_login');

And here is my js file

jQuery(document).ready(function(){
  jQuery('#user_login').attr('placeholder', 'Name');
  jQuery('#user_email').attr('placeholder', 'Email');
  jQuery('#user_pass').attr('placeholder', 'Password');
});

And this is where I get stuck .. in my mind that should work, I've checked the IDs and they all seem to line up but I'm clearly doing something wrong, you can see the page here http://www.camp-site-finder.com/wp-login.php

If you view the source you can see the link to my .js file and I'm referencing jQuery so errmm, have I done something stupid along the way or is there a better way of doing this?

If anyone can point me in the right direction on this one I'd be very grateful

N

  • 写回答

1条回答 默认 最新

  • doudouwen2763 2017-12-05 16:44
    关注

    you didn't include .JS file in <script src="something.js"> . you have included it in <link rel=stylesheet > tag that's the problem i have found in your page

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码