在Wordpress中使用AJAX进行a-z后查询

时间:2021-02-25 03:54:17

I'm looking to create a navigation for posts that queries all posts and returns those starting with a certain letter. I'd like this to be AJAX-based, so as to avoid reloading the page.

我正在寻找为查询所有帖子的帖子创建导航,并返回以某个字母开头的帖子。我希望这是基于AJAX的,以避免重新加载页面。

The navigation would be a simple < ul > and look like:

导航将是一个简单的

    ,看起来像:

[ # ] [ A ] [ B ] [ C ] ... [ Z ]

[#] [A] [B] [C] ...... [Z]

As one clicks on each < li >, all posts would be queried, and those whose post_title starts with the < li > 's letter would be returned.

当点击每个

  • 时,将查询所有帖子,并返回post_title以
  • 时,将查询所有帖子,并返回POST_TITLE以
  • 的字母开头的帖子。

  • 的字母开头的帖子。
  • How could a system like this be implemented?

    如何实现这样的系统?

    1 个解决方案

    #1


    1  

    • Use range('A', 'Z') to make the list
    • 使用范围('A','Z')来制作列表
    • Run a MySQL query where SUBSTRING(1, 1) == {escapedChar}
    • 运行MySQL查询,其中SUBSTRING(1,1)== {escapedChar}

    #1


    1  

    • Use range('A', 'Z') to make the list
    • 使用范围('A','Z')来制作列表
    • Run a MySQL query where SUBSTRING(1, 1) == {escapedChar}
    • 运行MySQL查询,其中SUBSTRING(1,1)== {escapedChar}