andyasher55
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
Forum: Fixing WordPress
In reply to: Display 4 more posts from same categoryDoh! Nevermind, I stumbled on a solution.
Forum: Fixing WordPress
In reply to: Display 4 more posts from same categoryMichael,
I’m trying hard to modify your fabulous patch…A similar situation to souverian.
I’m trying to show more posts from the selected category, but am using a custom field for the thumbail.
http://nicolasheller.com/test/?p=1
Here is the thumbnail code:
<!-- Begin Thumbnail --> <?php $postimageurl = get_post_meta($post->ID, 'post-img', true); if ($postimageurl) { ?> <a href="<?php the_permalink($cat_post->ID); ?>" rel="bookmark"><img src="<?php echo $postimageurl; ?>" alt="thumbnail" /></a> <?php } else { ?> <a href="<?php the_permalink($cat_post->ID); ?>" rel="bookmark"><img src="<?php bloginfo('template_url'); ?>/images/_.jpg" alt="thumbnail" /></a> <?php } ?> <!-- End Thumbnail -->How would I adapt this to what you provided?:
<?php global $post; $cat_ID=array(); $categories = get_the_category(); //get all categories for this post foreach($categories as $category) { array_push($cat_ID,$category->cat_ID); } $args = array( 'orderby' => 'date', 'order' => 'DESC', 'post_type' => 'post', 'numberposts' => 8, 'post__not_in' => array($post->ID), 'category__in' => $cat_ID ); // post__not_in will exclude the post we are displaying $cat_posts = get_posts($args); $out=''; foreach($cat_posts as $cat_post) { $out .= '<h1>'; $out .= '<a href="'.get_permalink($cat_post->ID).'" title="'.wptexturize($cat_post->post_title).'">'.wptexturize($cat_post->post_title).'</a></h1>'; } $out = '<ul class="cat_post">' . $out . '</ul>'; echo $out; ?>Thanks so much!
Viewing 2 replies - 1 through 2 (of 2 total)