Display thumbnails for only a specific category
-
So I am pulling the most recent image from my blog to my store (running osc).
This is the code that I have and it is currently working to pull the image, but I need to only pull the image from a specific category.
<?php // Include WordPress define('WP_USE_THEMES', false); require('./blog/wp-load.php'); query_posts('cat=14'); ?> <?php while (have_posts()): the_post(); ?> <?php function bdw_get_images() { // Get the post ID $iPostID = $post->ID; // Get images for this post $arrImages =& get_children('post_type=attachment&post_mime_type=image&post_parent=' . $iPostID ); // If images exist for this page if($arrImages) { // Get array keys representing attached image numbers $arrKeys = array_keys($arrImages); $iNum = $arrKeys[0]; $sThumbUrl = wp_get_attachment_thumb_url($iNum); $sImgString = '<a href="' . get_permalink() . '">' . '<img src="' . $sThumbUrl . '" width="150" height="150" alt="Thumbnail Image" title="Thumbnail Image" />' . '</a>'; // Print the image echo $sImgString; } } ?> <?php endwhile; ?> <?php bdw_get_images(); ?>
I tried adding the cat id to the posts query AND the get_posts to no avail. Any help is greatly appreciated
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Display thumbnails for only a specific category’ is closed to new replies.