将数组属性添加到implode()

时间:2017-09-27 22:43:51

标签: php arrays wordpress implode

我不懂PHP,但我必须参与其中。我需要使用$attr['ids']添加$gallery_setting数组。

function the_featured_image_gallery( $atts = array() ) {

    $gallery_setting = get_theme_mod( 'featured_image_gallery' );

    if ( is_array( $gallery_setting ) && ! empty( $gallery_setting ) ) {
        $atts['ids'] = implode( ',', $gallery_setting );

        echo gallery_shortcode( $atts );
    }
}

理想情况下,我想:

echo gallery_shortcode( $atts, array(
  'order'      => 'ASC',
  'size'       => 'full',
  'link'       => 'none'
) );

但我知道它不起作用。

1 个答案:

答案 0 :(得分:0)

请澄清你的问题。目前还不清楚你的问题是什么......

在黑暗中试拍:

function the_featured_image_gallery( $atts = array() ) {

    $gallery_setting = get_theme_mod( 'featured_image_gallery' );

    if ( is_array( $gallery_setting ) && ! empty( $gallery_setting ) ) {
        $atts['ids'] = implode( ',', $gallery_setting );

        $additional_atts = array(
          'order'      => 'ASC',
          'size'       => 'full',
          'link'       => 'none'
        );            
        $atts = array_merge($atts, $additional_atts);

        echo gallery_shortcode( $atts );
    }
}