尝试在3.5升级后修复我的自定义图库,并使用下面的代码尝试在内容输出上方获取图库的第一个“大”图像,然后在相应的图库中获取“缩略图”大小的剩余图像。。。但是由于某种原因,“numberposts”=>1不喜欢我正在做的事情。
那么,完全剥离gallery短代码(及其内容)的诀窍是什么呢?
single.php
<?php //GETS THE FIRST IMAGE
$args = array(
\'order\' => \'ASC\',
\'orderby\' => \'menu_order\',
\'post_type\' => \'attachment\',
\'post_parent\' => $post->ID,
\'post_mime_type\' => \'image\',
\'post_status\' => null,
\'numberposts\' => 1,
);
$attachments = get_posts($args);
if ($attachments) {
foreach ($attachments as $attachment) {
echo wp_get_attachment_link($attachment->ID, \'thumbnail\', false, false);
}
} else {
$post_content = $post->post_content;
preg_match(\'/\\[gallery.*ids=.(.*).\\]/\', $post_content, $ids);
$attachment_ids = explode(",", $ids[1]);
foreach ($attachment_ids as $attachment_id) {
echo wp_get_attachment_link($attachment_id, \'medium\', false, false);
}} ?>
<?php the_content(); ?>
<?php //GETS REMAINING IMAGES
$args = array(
\'order\' => \'ASC\',
\'orderby\' => \'menu_order\',
\'post_type\' => \'attachment\',
\'post_parent\' => $post->ID,
\'post_mime_type\' => \'image\',
\'post_status\' => null,
\'numberposts\' => -1,
);
$attachments = get_posts($args);
if ($attachments) {
$no_show=true;
foreach ($attachments as $attachment) {
if($no_show) {$no_show=false; continue; }
echo wp_get_attachment_link($attachment->ID, \'thumbnail\', false, false);
}
} else {
$post_content = $post->post_content;
preg_match(\'/\\[gallery.*ids=.(.*).\\]/\', $post_content, $ids);
$attachment_ids = explode(",", $ids[1]);
foreach ($attachment_ids as $attachment_id) {
echo wp_get_attachment_link($attachment_id, \'thumbnail\', false, false);
}}?>