Trying to fix my custom gallery after the 3.5 upgrade, and using the code below I'm trying to get the first image of the gallery in "large" size above the content output followed by the remaining images in the corresponding gallery in "thumbnail" size...but 'numberposts' => 1 isn't liking what I'm doing for some reason.
And, what's the trick to completely stripping the gallery shortcode [and it's contents] out?
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);
}}?>