小编Док*_*инг的帖子

如何在WordPress短代码中使用AJAX?

我有一个代码来显示随机引用.一个人写了一个函数来实现所有这些.但由于某些原因,通过AJAX更新数据不起作用.当您按下"新报价"按钮时,没有任何反应.也许有人知道为什么?需要在以下代码中修复哪些内容,以便在单击"新引号"时加载新引号?

PHP

/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)

HTML结构

在页面内容,窗口小部件或模板文件中:

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

php ajax wordpress shortcode

69
推荐指数
2
解决办法
2万
查看次数

如何在Notepad ++中更改正则表达式中的字母大小写

例如,有很多这样的行:"术语 - 定义".因为Notepad ++中的正则表达式可以用"大写"字母写成"术语" - TERM?

谢谢!

regex text notepad++

9
推荐指数
1
解决办法
5083
查看次数

标签 统计

ajax ×1

notepad++ ×1

php ×1

regex ×1

shortcode ×1

text ×1

wordpress ×1