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">
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


  • 写回答



      相关推荐 更多相似问题


      • ¥15 这段有什么bug 为什么总报错
      • ¥15 关于#php#根据url判断选择加载模板应该如何解决?会的速来捡钱!
      • ¥15 Intel Realsense深度相机(D415/D435)拍摄梯子获取梯子点云
      • ¥50 unity使用easyar录屏更换视频保存路径
      • ¥15 CECGameSession::OutputLinkSevError(iRetCode=4) LINK超时
      • ¥20 出错 textread (第 124 行) [varargout{1:nlhs}]=dataread('file',varargin{:}); %#ok<REMFF1>
      • ¥15 tensor flow目标检测环境配置问题
      • ¥15 数据库float型转换精度问题
      • ¥15 运行您代码时出现报错,如何解决?(标签-回归|关键词-无法识别)
      • ¥50 android service弹出dialog,showdialog就出错,如何解决?