ギャラリーのショートコード「exclude」が効かない
-
初めて質問させて頂きます。
graphpaperpress.comというところの、
「Retouch Pro」(※デモページ)
というテーマを使っています。このテーマには投稿フォーマットが「標準」「投稿」「ギャラリー」とあるんですが、
この中でフォーマットを「ギャラリー」と設定した時に、
デフォルトのショートコード「exclude」が機能してくれません。そもそもPHPのことが殆ど分からないので、
functions.phpでオーバーライドしている、のかな、くらいの見当しかつきません。
私はただ、[gallery exclude='画像ID']をきちんと機能させたいだけなのですが、
何をどうすればよいのか、教えて頂けますでしょうか?以下、コードを転載します。
何卒よろしくお願いします。functions.php
//hide gallery shortcode function gpp_the_gallery_content($content) { global $post_id; $format = get_post_format($post_id); if ($format == 'gallery') { $content = strip_shortcodes($content); return $content; } else { return $content; } } add_filter('the_content', 'gpp_the_gallery_content'); add_shortcode('gallery', 'gpp_retouch_gallery_shortcode'); /** * The Gallery shortcode. */ function gpp_retouch_gallery_shortcode($attr) { global $post; static $instance = 0; $instance++; // Allow plugins/themes to override the default gallery template. $output = apply_filters('post_gallery', '', $attr); if ( $output != '' ) return $output; // We're trusting author input, so let's at least make sure it looks like a valid orderby statement if ( isset( $attr['orderby'] ) ) { $attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] ); if ( !$attr['orderby'] ) unset( $attr['orderby'] ); } extract(shortcode_atts(array( 'order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail', 'include' => '', 'exclude' => '' ), $attr)); $id = intval($id); if ( 'RAND' == $order ) $orderby = 'none'; if ( !empty($include) ) { $include = preg_replace( '/[^0-9,]+/', '', $include ); $_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) ); $attachments = array(); foreach ( $_attachments as $key => $val ) { $attachments[$val->ID] = $_attachments[$key]; } } elseif ( !empty($exclude) ) { $exclude = preg_replace( '/[^0-9,]+/', '', $exclude ); $attachments = get_children( array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) ); } else { $attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) ); } if ( empty($attachments) ) return ''; if ( is_feed() ) { $output = "\n"; foreach ( $attachments as $att_id => $attachment ) $output .= wp_get_attachment_link($att_id, $size, true) . "\n"; return $output; } $itemtag = tag_escape($itemtag); $captiontag = tag_escape($captiontag); $columns = intval($columns); $itemwidth = $columns > 0 ? floor(100/$columns) : 100; $float = is_rtl() ? 'right' : 'left'; $selector = "gallery-{$instance}"; $gallery_style = $gallery_div = ''; $size_class = sanitize_html_class( $size ); $gallery_div = "<div id='$selector' class='gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>"; $output = apply_filters( 'gallery_style', $gallery_style . "\n\t\t" . $gallery_div ); $i = 0; $j=0; foreach ( $attachments as $id => $attachment ) { if ( $columns > 0 && ++$i % $columns == 0 ) { $class = " last"; } else { $class = ""; } $link = wp_get_attachment_image($id, $size, 0); $output .= "<{$itemtag} class='gallery-item" . $class . "'>"; $output .= " <{$icontag} class='gallery-icon'> $link </{$icontag}>"; if ( $captiontag && trim($attachment->post_excerpt) ) { $output .= " <{$captiontag} class='wp-caption-text gallery-caption'> " . wptexturize($attachment->post_excerpt) . " </{$captiontag}>"; } $output .= "</{$itemtag}>"; } $output .= "<div id='ph'></div><div id='lnav'>Left</div><div id='phbox'>"; foreach ( $attachments as $id => $attachment ) { $output .= '<div class="mainimgcontainer '.$j.'">'; $output .= '<div class="imgcontainer">'; $output .= wp_get_attachment_image($id, "large", 0); $output .= '</div>'; if($attachment->post_excerpt == "" && post_exif($id) == "" ){ } else { $output .= '<div class="gallery-exif">'; $output .= '<span class="g-caption">'.$attachment->post_excerpt.'</span>'; $output .= '<div class="galexif-content">'; $output .= post_exif($id); $output .= '</div></div><div class="g-exif-info">info</div>'; } $output .= '<div class="clear"></div></div>'; $j++; } $output .= "</div><div id='rnav'>Right</div>\n"; $output .="<div class='clear'></div>"; $output .= "</div>\n"; return $output; } function dec2frac($dec) { global $result; $count = 0; $result = array(); decimalToFraction($dec, $count, $result); $count = count($dec); return simplifyFraction($result,$count,1,$result[$count]); } function decimalToFraction($decimal,$count,$result) { global $result; $a = (1/$decimal); $b = ( $a - floor($a) ); $count++; if ($b > .01 && $count <= 5) decimalToFraction($b,$count,$result); $result[$count] = floor($a); } function simplifyFraction($fraction,$count,$top,$bottom) { if($count>1){ $next = $fraction[$count-1]; } else { $next = ""; } $a = ($bottom * $next) + $top; $top = $bottom; $bottom = $a; $count--; if ($count > 0) simplifyFraction($fraction,$count,$top,$bottom); else { return "$bottom/$top"; } }
content-gallery.php(投稿フォーマット ※デフォルトから少し触ってます)
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <div id="collection" class="entry-content"> <header class="entry-header"> <h2 class="entry-title"><?php the_title(); ?></h2> </header> <!-- .entry-header --> <div class="post-thumbnail"><?php echo do_shortcode("[gallery columns='3']"); ?></div> <div class="clear"></div> </div> <!-- .entry-content --> <div class="meta-data"> <span class="info-meta"><a href="#content"><?php printf(__( 'product information','gpp_lang' )); ?></a></span> <?php if ( comments_open() || ( '0' != get_comments_number() && ! comments_open() ) ) : ?> <span class="comments-link"> <?php comments_popup_link( __( 'Leave a comment','gpp_lang' ), __( '1 Comment','gpp_lang' ), __( '% Comments','gpp_lang' ) ); ?> </span> <?php endif; ?> </div> <div id="info_content" class="main-content"> <?php the_content(); ?> </div> </article> <!-- #post-<?php the_ID(); ?> -->
7件の返信を表示中 - 1 - 7件目 (全7件中)
7件の返信を表示中 - 1 - 7件目 (全7件中)
- トピック「ギャラリーのショートコード「exclude」が効かない」には新たに返信することはできません。