【问题标题】:Ajax to filter and display gallery thumbnails in wordpressAjax 在 wordpress 中过滤和显示画廊缩略图
【发布时间】:2013-03-05 12:32:34
【问题描述】:

使用 wordpress 模板,因为小型会议网站的截止日期很紧。有一个“添加员工”选项和 [staff] 短代码,允许添加会议参与者。 STaff 也可以按部门标记。不幸的是,没有办法按部门动态过滤员工,因此只显示特定部门的员工。

Ideally I'd like a select dropdown with a list of departments, that when selected would filter and display ONLY staff in that department.

显示特定部门的简码很简单

[员工部门="DEPARTMENT_NAME" /]

是否有一些我可以使用的通用 ajax 可以实现这一点?

【问题讨论】:

    标签: wordpress filter shortcode


    【解决方案1】:

    为了让 ajax 在 wordpress 中正常工作,您需要创建 ajax 处理程序,创建 php 文件并包含 'wp-load.php' 是一种不好的做法,本文http://wp.tutsplus.com/articles/getting-started-with-ajax-wordpress-pagination/ 将解释使用 ajax 的正确做法。

    您可以在ajax请求的查询参数中发送部门名称,并在处理您的ajax请求的函数中使用wordpressdo_shortcode('[staff department="DEPARTMENT_NAME" /]')。打印从do_shortcode() 生成的 html 并在 ajax 成功回调上替换适当的 <div> 的 html。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多