I am trying to figure out if this: http://www.portlandonfire.com/archive/ is custom work, or a plugin, or a setting?
Thanks in advance for any help!
I am trying to figure out if this: http://www.portlandonfire.com/archive/ is custom work, or a plugin, or a setting?
Thanks in advance for any help!
The answer would be "custom work" using WordPress functionality. This is pretty easy to achieve. Just plug the following code into your themes' archives.php file make sure you overwrite the Loop that you have in there right now:
<?php
/* WordPress Loop - Display only linked thumbnails
==================================================== */
if (have_posts()) :
while (have_posts()) : the_post(); update_post_caches($posts);
$images = get_children(
array(
'post_parent' => $post->ID,
'numberposts' => 1,
'post_status' => 'inherit',
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => 'ASC',
'orderby' => 'menu_order'
)
);
if ( $images ) {
foreach ( $images as $id => $image ) {
$img = wp_get_attachment_thumb_url( $image->ID );
$link = get_permalink( $post->ID );
print "\n\n" . '<a class="alignleft" href="' . $link . '"><img src="' . $img . '" alt="" />';
}
}
endwhile;
print '<div class="clear"></div>';
else :
print '<div class="errorbox">' . __('Sorry, no posts matched your criteria.') . '</div>';
endif;
?>Do you know how I could make this work with the listing of pages instead of posts?
Solved my problem:
<?php
query_posts('post_type=page&post_parent='.$parent);
?>
<?php
/* WordPress Loop - Display only linked thumbnails
==================================================== */
if (have_posts()) :
while (have_posts()) : the_post(); update_post_caches($posts);
$images = get_children(
array(
'post_parent' => $post->ID,
'numberposts' => -1,
'post_status' => 'inherit',
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => 'ASC',
'orderby' => 'menu_order'
)
);
if ( $images ) {
foreach ( $images as $id => $image ) {
$img = wp_get_attachment_thumb_url( $image->ID );
$link = get_permalink($page->ID);
echo "\n\n" . '<a class="alignleft" href="' . $link . '"><img src="' . $img . '" alt="" /></a>';
}
}
endwhile;
echo '<div class="clear"></div>';
else :
echo '<div class="errorbox">' . __('Sorry, no posts matched your criteria.') . '</div>';
endif;
?>This topic has been closed to new replies.