dsfd3546 2015-07-22 17:03
浏览 188
已采纳

如何在WordPress中搜索我的数据库以获取自定义字段的所有选项?

I'm in a custom taxonomy page and I need to display all the options of a particular custom field called "Region". I tried doing a database query for all the possible values, however because multiple regions are selectable in the custom field, the resulted values are the many different combinations of regions (such as "Asia, Africa, Europe" as one, "Central America, North America" as another and "Europe, Central America", etc etc.)

I want to retrieve just them just singularly, ("Asia" as one, "Europe" as another, etc. etc.) How would I go about doing this?

  • 写回答

1条回答 默认 最新

  • douguomou5094 2015-07-23 04:21
    关注

    You can use some basic coding approach of php.

    Approach:

    Use the explode() function of php and set the values in an array for each meta value with a key 'coffee_region' (adding each meta value in the a single array. Make sure you are adding elements not overwriting the previous values of meta in array).

    Then use array_unique() function to get rid of the repetitive countries from the array.

    And when you print that array you will be having a listing of unique country names from the meta fields

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

报告相同问题?

悬赏问题

  • ¥15 设计一个光控计数器,全部用ttl芯片
  • ¥15 vscode platformio
  • ¥15 代写uni代码,app唤醒
  • ¥15 全志t113i启动qt应用程序提示internal error
  • ¥15 ensp可以看看嘛.
  • ¥80 51单片机C语言代码解决单片机为AT89C52是清翔单片机
  • ¥60 优博讯DT50高通安卓11系统刷完机自动进去fastboot模式
  • ¥15 minist数字识别
  • ¥15 在安装gym库的pygame时遇到问题,不知道如何解决
  • ¥20 uniapp中的webview 使用的是本地的vue页面,在模拟器上显示无法打开