最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wpdb - Populate shortcodes with table data and get next row

programmeradmin1浏览0评论

Let's say I have a database table wp_myplugin_cars that looks like this:

id   name    color   make
--   ----    -----   ----
1    Peter   Red     Ford
2    Jo      Blue    Nissan
3    Brian   Silver  Toyota
... plus n more rows

Let's say I have a plugin setting field which is a wp_editor and inside that, the user can choose how to display their data using my plugin. They might save something like:

<h1>Cars and people list</h1>
[myplugin-name] drives a [myplugin-color] [myplugin-make]

My problem is that (with my current knowledge), I can only output:

Cars and people list

Peter drives a Red Ford

So my question is: when adding shortcodes, how can I "move to the next row" just like the Next Record field in Microsoft Word mail merge. I.e., is the following possible?

<h1>Cars and people list</h1>
[myplugin-name] drives a [myplugin-color] [myplugin-make] [myplugin-NEXTRECORD]

The desired result being:

Cars and people list

Peter drives a Red Ford

Jo drives a Blue Nissan

Brian drives a Silver Toyota

... and so on...

发布评论

评论列表(0)

  1. 暂无评论