您好我试图通过添加jquery来循环浏览我的图像而不是将其显示为单独的图片链接来操纵wordpress中的默认图库。但是,我似乎无法找到要更改的文件 - 我想弄清楚如何自定义默认库(最好没有插件)..任何想法将不胜感激。
答案 0 :(得分:0)
add_filter( 'post_gallery', 'your_gallery_func', 10, 2);
your_gallery_func
中你需要模仿默认图库并提取atts:/*
* Extract default gallery settings
*/
extract(shortcode_atts(array(
'order' => 'ASC',
'orderby' => 'menu_order ID',
'id' => $post->ID,
'itemtag' => 'dl',
'icontag' => 'dt',
'captiontag' => 'dd',
'columns' => 3,
'size' => 'thumbnail',
), $attr));
$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 '';
这只是一个例子:
/**
* Open the gallery <div>
*/
$output .= '<div id="gallery-'.$id.'" class="content gallery gallery-'.$id.'">'."\n";
$output .= '<div id="thumbs" class="navigation">'."\n";
/**
* Loop through each attachment
*/
foreach ( $attachments as $id => $attachment ) :
/**
* Open each gallery item
*/
$output .= "\n\t\t\t\t\t<li class='gallery-item'>";
$output .= '<a class="thumb" href="' . $link[0] . '" title="' . $title . '">';
$output .= '<img src="' . $img[0] . '" alt="' . $title . '" title="' . $title . '" />';
$output .= '</a>';
/**
* Close individual gallery item
*/
$output .= "\n\t\t\t\t\t</li>";
endforeach;
/**
* Close gallery and return it
*/
$output .= '</ul><!--.thumbs-->'."\n";
$output .= '</div><!--#gallery-wrap-->'."\n";
return $output;