drnvcm3949 2014-06-23 11:09
浏览 118
已采纳

在WordPress中处理自定义表数据

I'm making a plugin for WordPress and it requires some custom tables of mine (or the data in them, to be specific). These tables are simple. They only contain an id and a varchar field. Do not mention meta fields. I am using custom tables for a reason. The problem is, I need to allow the user to edit the data in these tables. To insert, update and delete rows in the tables. How do I handle this in WordPress?

I can make my own custom pages and create a whole system for editing, inserting and updating them but that's a workaround since none of that would be native to WordPress.

The only thing I came up with is making them into custom post types and having WordPress let me use its native adding, editing and deleting menu (the same one used in posts, pages, etc.). Though then new problems would arise. I need to connect the post ids to the rows in the custom tables and be very careful when editing, updating and deleting to make sure that both the posts and my custom table data remain consistent with each other. And that's a whole new layer of complexity.

So I was wondering if there's an elegant way to handle these sorts of simple tables. If there isn't I'll find my own workaround.

EDIT:

The plugin I'm making is supposed to turn your WordPress site into a kind of an ad posting site. And I need the custom tables to provide details about the ads.

  • 写回答

1条回答 默认 最新

  • douvcpx6526 2014-06-23 12:09
    关注

    refer this codex Wp_list_table. you can play with custom table data. for more you can go through an example plugin.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决