Created
September 23, 2014 17:43
-
-
Save johnbhartley/3a91b63022ea800e15e5 to your computer and use it in GitHub Desktop.
use gallery ids to output however you want.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// into template or another filter i suppose | |
$pattern = get_shortcode_regex(); | |
if( preg_match_all( '/'. $pattern .'/s', $post->post_content, $matches ) | |
&& array_key_exists( 2, $matches ) | |
&& in_array( 'gallery', $matches[2] ) ): | |
$keys = array_keys( $matches[2], 'gallery' ); | |
foreach( $keys as $key ): | |
$atts = shortcode_parse_atts( $matches[3][$key] ); | |
if( array_key_exists( 'ids', $atts ) ): | |
$thumbs = array(); | |
$images = new WP_Query( | |
array( | |
'post_type' => 'attachment', | |
'post_status' => 'inherit', | |
'post__in' => explode( ',', $atts['ids'] ), | |
'orderby' => 'post__in' | |
) | |
); | |
if( $images->have_posts() ): | |
// loop over returned images | |
var_dump(); | |
foreach($images->query['post__in'] as $id) { | |
$full = wp_get_attachment_image_src( $id, 'full' ); | |
$thumb = wp_get_attachment_image_src( $id, 'map-thumb' ); | |
echo '<li>'; | |
echo ' <img src="'.$full[0].'" />'; | |
echo '</li>'; | |
$thumbs[] = $thumb[0]; | |
} | |
endif; | |
wp_reset_query(); | |
endif; | |
endforeach; | |
endif; | |
// into functions.php | |
function my_gallery_shortcode( $output = '', $atts, $content = false, $tag = false ) { | |
return '<div class="clear"></div>'; | |
} | |
add_filter( 'post_gallery', 'my_gallery_shortcode', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment