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">
add_action('login_head', 'my_custom_login');

And here is my js file

  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

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


图片转代码服务由CSDN问答提供 功能建议

所以我想在标准的wp-login.php页面上的“用户名”和“密码”字段中添加占位符文本 - I 不想编辑实际的wp-login.php页面,因为每次更新WordPress时我的修改都会被删除。

所以! 在functions.php中我添加了一个简单的函数来添加一个.js文件(以及一些css文件,但我认为这对此不重要)到wp-login.php页面,我有这段代码 - 这是我的 function.php中的函数

  function my_custom_login(){
 echo'&lt; link rel =“stylesheet”type =“text / css”href =“/ shared-assets  /css/main-screen-styles.css“/&gt;'; 
 echo'&lt; link rel =”stylesheet“type =”text / css“href =”'。get_bloginfo('stylesheet_directory')。'/ css  /campsite-finder-screen-styles.css“/&gt;'; 
 echo'&lt; script type =”text / javascript“href =”/ shared-assets / js / test.js“&gt; 
&lt; / 脚本&gt;'; 


 jQuery('#user_email')。attr(  'placeholder','Email'); 
 < 这就是我被卡住的地方..在我的脑海里 这应该工作,我已经检查了ID,他们似乎排队但我显然做错了,你可以看到这里的页面   

如果你 查看源代码,你可以看到我的.js文件的链接,我正在引用jQuery这么错误,我有没有做过一些愚蠢的事情或者有更好的方法吗?



  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

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

    解决 无用
    打赏 举报

相关推荐 更多相似问题