WordPress.org

Make WordPress Core

Ticket #14390: exclude_post_thumbnail_from_gallery_shortcode.diff

File exclude_post_thumbnail_from_gallery_shortcode.diff, 688 bytes (added by nkuttler, 4 years ago)
  • wp-includes/media.php

    diff --git a/wp-includes/media.php b/wp-includes/media.php
    index 4003a41..50be3ee 100644
    a b function gallery_shortcode($attr) { 
    788788        if ( 'RAND' == $order ) 
    789789                $orderby = 'none'; 
    790790 
     791        // Always exclude the post thumbnail 
     792        if ( empty( $exclude ) ) 
     793                $exclude = get_post_thumbnail_id(); 
     794        else 
     795                $exclude .= ',' . get_post_thumbnail_id(); 
     796 
    791797        if ( !empty($include) ) { 
    792798                $include = preg_replace( '/[^0-9,]+/', '', $include ); 
    793799                $_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );