• hello
    I have new to wordpress script
    just have code show featured post from all category and I want to now what should i change to make it for example show featured posts of category 1
    this is the code

    thanks in advance for any help

    <div id="featured">
    
    	<div id="featuredleft">
    
    	<ul id="featuredposts" class="featuredposts">
    	<?php
    	for($i = 1; $i <= $opt['fcatn']; $i++) {
    	?>
    	<li><a href="#" rel="cat<?=$i?>" class="<?php if($i==1) print 'selected'; ?>"><?php query_posts('cat='.$opt['cat'.$i]); ?><?php single_cat_title(); ?></a></li>
    	<?php
    	}
    	?>
    	</ul>
    	<div class="clear"></div>
    
    	<?php
    	for($i = 1; $i <= $opt['fcatn']; $i++) {
    	?>
    	<div id="cat<?=$i?>" class="featuredposts_content">
    	<?php query_posts('showposts=1&cat='.$opt['cat'.$i]); ?>
    	<?php while (have_posts()) : the_post(); ?>
    	<div class="thumb"><?php echo get_the_image(array('Thumbnail','My Thumbnail'),'thumbnail'); ?></div>
    	<div class="post">
    
    		<h1><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h1>
    		<div class="time"><?php the_time('l, F j, Y G:i'); ?></div>
    		<div class="entry"><p><?php the_excerpt_reloaded($opt['fexcerpt'], '<a>', FALSE, FALSE, 2); ?></p></div>
    
    		<div class="endpost">
    		<div class="cat"><a href="<?php echo get_category_link($opt['cat'.$i]); ?>"><?=$l_opt['word54']?> <?php single_cat_title(); ?></a></div>
    		<ul class="extra">
    		<li><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?=$l_opt['word4']?></a></li>
    		<li class="comments"><a href="<?php the_permalink() ?>#commenting" title="<?=$l_opt['word5']?>"><?php comments_number($l_opt['word9'],$l_opt['word10'],'% '.$l_opt['word11']); ?></a></li>
    		</ul>
    		</div><div class="clear"></div>
    
    	</div><div class="clear">
    	</div>
    	<?php endwhile; ?>
    	</div>
    	<?php
    	}
    	?>
    
    	<script type="text/javascript">
    	var featuredposts=new ddtabcontent("featuredposts")
    	featuredposts.setpersist(true)
    	featuredposts.setselectedClassTarget("link")
    	featuredposts.init()
    	</script>
    
    	</div>
    	<div id="featuredright">
    
    	<ul id="featuredtabs" class="featuredtabs">
    	<li><a href="#" rel="popular" class="selected"><?=$l_opt['word55']?></a></li>
    	<li><a href="#" rel="recent"><?=$l_opt['word56']?></a></li>
    	<li><a href="#" rel="comments"><?=$l_opt['word57']?></a></li>
    	<li><a href="#" rel="tags"><?=$l_opt['word58']?></a></li>
    	</ul>
    	<div class="clear"></div>
    
    	<div id="popular" class="featuredtabs_content">
    	<ul>
    	<?php
    	$now = gmdate("Y-m-d H:i:s",time());
    	$ap = $opt["popular"];
    	$popularposts = "SELECT ID, post_title, post_date, comment_count, COUNT($wpdb->comments.comment_post_ID) AS 'popular' FROM $wpdb->posts, $wpdb->comments WHERE comment_approved = '1' AND $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND post_status = 'publish' AND post_date < '$now' AND comment_status = 'open' GROUP BY $wpdb->comments.comment_post_ID ORDER BY popular DESC LIMIT $ap";
    	$posts = $wpdb->get_results($popularposts);
    	$popular = '';
    	if($posts){
    	foreach($posts as $post){
    	$post_title = stripslashes($post->post_title);
    	$post_date = stripslashes($post->post_date);
    	$comments = stripslashes($post->comment_count);
    	$guid = get_permalink($post->ID);
    	$popular .= '<li><a href="'.$guid.'" title="'.$post_title.'">'.$post_title.'</a>
    	<span>'.$l_opt['word59'].' <a href="'.$guid.'#commenting" title="'.$l_opt['word60'].' '.$post_title.'">'.$comments.' '.$l_opt['word11'].'</a> '.$l_opt['word61'].' '.$post_date.'</span></li>';
    	}
    	}echo $popular;
    	?>
    	</ul>
    	</div>
    
    	<div id="recent" class="featuredtabs_content">
    	<ul>
    	<?php query_posts('showposts='.$opt["posts"].'&orderby=date'); ?>
    	<?php while (have_posts()) : the_post(); ?>
    	<li><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
    	<span><?=$l_opt['word59']?> <?php comments_popup_link($l_opt['word9'],$l_opt['word10'],'% '.$l_opt['word11']); ?> <?=$l_opt['word61']?> <?php the_time('l, F j, Y G:i'); ?></span></li>
    	<?php endwhile; ?>
    	</ul>
    	</div>
    
    	<div id="comments" class="featuredtabs_content">
    	<?php if (function_exists('src_simple_recent_comments')) { src_simple_recent_comments($opt["comments"], $opt["cexcerpt"], '', ''); } ?>
    	</div>
    
    	<div id="tags" class="featuredtabs_content">
    	<?php wp_tag_cloud('smallest=8&largest=14&number='.$opt["tags"]); ?>
    	</div>
    
    	<script type="text/javascript">
    	var featuredtabs=new ddtabcontent("featuredtabs")
    	featuredtabs.setpersist(false)
    	featuredtabs.setselectedClassTarget("link")
    	featuredtabs.init()
    	</script>
    
    	</div>
    	<div class="clear"></div>
    
    </div>
  • The topic ‘specifed feautred code to show from specifeid category’ is closed to new replies.