Created
December 18, 2015 02:27
-
-
Save alenabdula/dea463d2c8186eae47d8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
/** | |
* Disable Default Gallery | |
*/ | |
remove_shortcode('gallery', 'gallery_shortcode'); | |
/** | |
* Custom Gallery | |
*/ | |
add_shortcode( 'gallery', 'custom_gallery_shortcode' ); | |
function custom_gallery_shortcode( $attributes ) { | |
$data = shortcode_atts( array( | |
'ids' => '' | |
), $attributes ); | |
$image_ids = explode(',', $data['ids']); | |
$view = '<div class="wrap">'; | |
$counter = 0; | |
foreach ($image_ids as $id) { | |
if ( $counter % 3 == 0 ) { | |
$view .= $counter > 0 ? '</div>' : ''; | |
$view .= '<div class="row">'; | |
} | |
$view .= '<div class="col">'; | |
$view .= '<img src="'.wp_get_attachment_thumb_url($id).'">'; | |
$view .= '</div>'; | |
$counter++; | |
} | |
$view .= '</div>'; | |
return $view; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment