Skip to content

Instantly share code, notes, and snippets.

@backslash7
Created April 8, 2015 12:13
Show Gist options
  • Save backslash7/ece5d459253c41eb75cc to your computer and use it in GitHub Desktop.
Save backslash7/ece5d459253c41eb75cc to your computer and use it in GitHub Desktop.
Fix Wordpress gallery showing only to logged in users
function quickhack_fix_gallery( $query ) {
if ( $query->get( 'post_type', '' ) == 'attachment' ) {
$query->set( 'post_status', 'inherit' );
}
}
add_action( 'pre_get_posts', 'quickhack_fix_gallery', 99 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment