我有一个代码来显示随机引用.一个人写了一个函数来实现所有这些.但由于某些原因,通过AJAX更新数据不起作用.当您按下"新报价"按钮时,没有任何反应.也许有人知道为什么?需要在以下代码中修复哪些内容,以便在单击"新引号"时加载新引号?
/wp-content/themes/%your_theme%/js/ajax-load-quote.php
<?php
/* uncomment the below, if you want to use native WP functions in this file */
// require_once('../../../../wp-load.php');
$array = file( $_POST['file_path'] ); // file path in $_POST, as from the js
$r = rand( 0, count($array) - 1 );
return '<p>' . $array[$r] . '</p>';
?>
Run Code Online (Sandbox Code Playgroud)
在页面内容,窗口小部件或模板文件中:
<div id="randomquotes">
<p>I would rather have my ignorance than another man’s knowledge,
because I have so much more of it.<br />
-- Mark Twain, American author & …Run Code Online (Sandbox Code Playgroud) 例如,有很多这样的行:"术语 - 定义".因为Notepad ++中的正则表达式可以用"大写"字母写成"术语" - TERM?
谢谢!