Last active
December 17, 2015 03:39
-
-
Save shaynesanderson-zz/5545196 to your computer and use it in GitHub Desktop.
Make featured image first in WP Gallery, no matter what order it's set in.
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
<?php | |
add_filter( 'shortcode_atts_gallery', 'test_post_gallery' ); | |
function test_post_gallery( $args ) { | |
$feat_id = get_post_thumbnail_id(); | |
// bail if no feat image ID | |
if ( !$feat_id ) | |
return $args; | |
$feat_id = $feat_id.','; | |
// is our feat imaage ID in in the gallery? | |
if ( strpos( $args['include'], $feat_id ) !== false ) { | |
// if so, move it to the front | |
$args['include'] = $feat_id . str_replace( $feat_id, '', $args['include'] ); | |
} | |
return $args; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment