3 posts from specific category in this code
-
Hi guys
Can you please help me out with my problem?
I would like to display 3 posts from specific category, let’s call it “SPECIFIC” with ID 234
Cureent code in home file is
<!-- Recent Posts --> <?php if(opt('home_recent_posts')) { $lastposts = get_posts( 'numberposts=3&suppress_filters=0' ); if(count($lastposts)) { ?> <div class="container"> <div class="row latest_blog_post"> <?php foreach($lastposts as $post) { setup_postdata($post); $postType = get_post_meta(get_the_ID(), 'content_type', true); $hasMedia = false; $vType = get_post_meta(get_the_ID(), 'video_server', true); $vID = get_post_meta(get_the_ID(), 'video_id', true); if($postType == '1' && function_exists('has_post_thumbnail') && has_post_thumbnail()) $hasMedia = true; else if($postType == '2') $hasMedia = true; $boxClass = $hasMedia ? '' : 'no-media'; ?> <div class="span4 box <?php echo $boxClass; ?>"> <a href="<?php the_permalink(); ?>"> <div class="meta"> <?php the_time('d'); ?> <span><?php the_time('M'); ?></span> </div> <?php if($postType == '1'){ ?> <div class="image"> <?php if ( function_exists('has_post_thumbnail') && has_post_thumbnail() ) the_post_thumbnail('recent-posts'); ?> </div> <?php } elseif($postType == '2') { ?> <div class="post_video"> <?php if($vType == '' || $vType == '1') { ?> <iframe width="560" height="315" src="http://www.youtube.com/embed/<?php echo $vID; ?>" frameborder="0" allowfullscreen></iframe> <?php } else {?> <iframe src="http://player.vimeo.com/video/<?php echo $vID; ?>?color=f0e400" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe> <?php } ?> </div> <?php } ?> </a> <h2> <a class="title" href="<?php the_permalink(); ?>"><?php the_title(); ?></a> </h2> <div class="separator"></div> <p> <?php $content = get_the_content(); if(strlen($content) <= 200) echo $content; else { $matches = array(); preg_match('/^.{0,200}(?:.*?)\b/iu', strip_tags($content), $matches); echo $matches[0] . '...'; } ?> </p> </div> <?php } ?> </div> </div> <?php }//If recent posts } ?>
I’m not programmer, so i’m kindly asking for a help 😉
Thank you
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘3 posts from specific category in this code’ is closed to new replies.