你说你是。。。
。。。想要添加一个随机的原因(引号),说明他们为什么应该加入,这将在每次重新加载页面后更改
您似乎试图通过在文本小部件中放置Javascript来实现这一点。我想这就是你所说的“站点中的文本”的意思。
基于这种描述,您不需要Javascript。您需要一个新的边栏小部件。
class Quote_Login extends WP_Widget {
/*constructs etc*/
function __construct($id = \'quologin\', $descr = \'Quote Login\', $opts = array()) {
$widget_opts = array();
parent::__construct($id,$descr,$widget_opts);
}
function widget() {
$ar = array(
\'“Nothing is as easy as it looks.”\',
\'“Everything takes longer than you think.”\',
\'“Anything that can go wrong will go wrong.”\',
\'“If there is a possibility of several things going wrong, the one that will cause the most damage will be the one to go wrong.”\',
\'“If there is a worse time for something to go wrong, it will happen then.”\',
\'“If anything simply cannot go wrong, it will anyway.”\',
\'“If you perceive that there are four possible ways in which a procedure can go wrong, and circumvent these, then a fifth way, unprepared for, will promptly develop.”\',
\'“Left to themselves, things tend to go from bad to worse.”\',
\'“If everything seems to be going well, you have obviously overlooked something.”\',
\'“Nature always sides with the hidden flaw.”\',
\'“Mother nature is a bitch.”\',
\'“It is impossible to make anything foolproof because fools are so ingenious.”\',
\'“Whenever you set out to do something, something else must be done first.”\',
\'“Every solution breeds new problems.”\',
\'“Trust everybody … then cut the cards.”\',
\'“Two wrongs are only the beginning.”\',
\'“If at first you don’t succeed, destroy all evidence that you tried.”\',
\'“To succeed in politics, it is often necessary to rise above your principles.”\',
\'“Exceptions prove the rule … and wreck the budget.”\',
\'“Success always occurs in private, and failure in full view.”\',
);
$quote = $ar[array_rand($ar,1)]; ?>
<p><b>It looks like you haven’t logged in or have not yet registered.<br>
To receive the most accurate results and member benefits, login below or click register to become a member.</b></p>
<center>
<form action="wp-login.php" method="LINK">
<b><br><input type="submit" value="LOGIN"><br></b>
</form>
</center>
<p></p>
<b><p>Why Become A Member?</p>
<form name="random">
<input type="text" value="" size="78" name="random" />
</form>
<?php
// here is your quote
// the curly quotes you apparently want won\'t work in the form input
// but I don\'t know why you are shoving this into an input anyway
echo $quote; ?>
<p></p><center>
<form action="wp-register.php" method="LINK"><br>
<input type="submit" value="REGISTER"><br>
</form>
</center><p></p>
</b><p><b>XCLO</b></p> <?php
}
}
add_action(\'widgets_init\', function() { register_widget("Quote_Login"); } );
只有在需要定期更改引号而不需要重新加载页面时,才需要Javascript。
我没有纠正你的基本标记(很多),但有几件事让我觉得奇怪,比如使用表单创建本质上是链接的内容,以及使用deprecated in HTML4 and unsupported in HTML5 elements like <center>