我如何将数组传递给shortocde wordpress

时间:2018-01-09 09:37:23

标签: php wordpress shortcode

当我使用短代码时,它会打印并出现错误

  

注意:第345行/home/nadiaz5/public_html/wp-includes/shortcodes.php中的数组到字符串转换

function ff_register_shortcode(){

    $danger="";

    $BoxLength=esc_attr( get_option('ff_list_boxes') ); 
    $fedex_feeding= array();

    $keys = array('name', 'id', 'max_weight', 'box_weight','length','width','height','inner_length','inner_width','inner_height','type');
    for($f=0 ; $f<$BoxLength;$f++){
        array_push($fedex_feeding, array(  
                'name'         => get_option('ff_name_'.$f),
                'id'           => get_option('ff_id_'.$f),
                'max_weight'   => get_option('ff_max_weight_'.$f), 
                'box_weight'   => get_option('ff_box_weight_'.$f),
                'length'       => get_option('ff_length_'.$f),
                'width'        => get_option('ff_width_'.$f),
                'height'       => get_option('ff_height_'.$f),
                'inner_length' => get_option('ff_inner_length_'.$f),
                'inner_width'  => get_option('ff_inner_width_'.$f),
                'inner_height' => get_option('ff_inner_height_'.$f),
                'type'         => get_option('ff_type_'.$f),
            )
        );
    }

    $danger = array();
    $BoxLength=esc_attr( get_option('ff_list_boxes') );
    for ($i=0; $i < $BoxLength; $i++) { 
        array_push($danger , $fedex_feeding[$i]);
    }

    return $danger;

}

add_shortcode('ff_arrays' , 'ff_register_shortcode');

0 个答案:

没有答案