PHP WordPress - Get Post's Galleries as Shortcode Arguments

<?php if ( $galleries = get_post_galleries( $post->ID, false ) ) { $defaults = array ( 'orderby' => 'menu_order ASC, ID ASC', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'full', 'link' => 'file', 'ids' => "", 'src' => array (), ); foreach ( $galleries as $gallery ) { // defaults $args = wp_parse_args( $gallery, $defaults ); // image ids $args[ 'ids' ] = explode( ',', $args[ 'ids' ] ); // image urls $images = $args[ 'src' ]; } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.