doudiaozhi6658 2014-07-08 07:57
浏览 18

显示基于ID或类名的数组

I've created an admin page for my wordpress theme to allow multiple images to be uploaded to my slideshow.

It works fine if there is only one slideshow form but if I add another one it no longer works as it should, the reason for this is that it counts the arrays and then takes a number away to display the amount of fields.

So instead of counting the arrays I would like to display them based on ID, so if there is 3 fields with the ID or class name then it will display 3 forms but this is all very new to me so I need a little help.

The id or class name is zzzclonedInput

Here's my form as it stands

function zzz_hero_image_option_callback() {
$hero_options = get_option( 'hero_options' ); 
$count=count($hero_options);
$totalimg=$count-4;
$html = '<div id="upload_zzz_sets">';
    for($i=1;$i<=$totalimg;$i++){ 
    if( isset( $hero_options['upload_zzz_link_1'] ) && $hero_options[ 'upload_zzz_link_1' ] ) { 
        $html .= '<div id="zzzclonedInput'.$i.'" class="zzzclonedInput">';
        $html .= '<input id="cs_product_menu_zzz_src_'.$i.'" type="text" size="36" name="hero_options[upload_zzz_link_'.$i.']" value="' . $hero_options['upload_zzz_link_'.$i.''] . '" /> <input id="cs_product_menu_zzz_src_'.$i.'_zzzbutton" type="button" value="Add / Change" class="button-secondary zzz-upload-button"  /> <div class="button zzzremove">-</div>';
        $html .= '</div>';
    }
    }
    $html .= '</div>';

    echo $html;
    ?> <div class="button zzzclone">Add an Image</div> <?php 
}

The bit I need to replace is this

$count=count($hero_options);
$totalimg=$count-4;

and

for($i=1;$i<=$totalimg;$i++){

Thanks for your help and if you need any other info let me know.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?