doutan5844 2011-07-18 07:31
浏览 29

如何通过添加下拉列表自定义我的wordpress帖子表单?

I m still a novice for WP. i need to customize my admin post form by adding drop down list. List options should be come from one of my WP database table's column....i found lots of plugin for adding new input field to my post form. but it is not supported to getting list option values from WP database to the drop down list. i m much thankful if someone can help me.

  • 写回答

2条回答 默认 最新

  • drs7798 2011-07-18 08:57
    关注

    You can make use of the global $wpdb object. The $wpdb object allows you to run queries on any table in the Wordpress database. For example:

    $query = "SELECT * FROM options WHERE parameter='value' ORDER by columnichoose DESC"
    $query = $wpdb->prepare($query);
    $results = $wpbd->get_results($query,ARRAY_A); // ARRAY_A tells it to return an associative array, objects and numeric arrays can also be selected.
    foreach ($results as $result)
    {
    $html .= "<option value='" . $result['columnneeded'] . "'>".$result['columnneeded'] . "</option>";
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line