Posted in Wordpress, 程序开发

wordpress栏目调用方式

ken 2009-11-09 Hit: 614
<ul class="catArchive">
	<?php
	$catQuery = $wpdb->get_results("SELECT * FROM $wpdb->terms AS wterms INNER JOIN $wpdb->term_taxonomy AS wtaxonomy ON ( wterms.term_id = wtaxonomy.term_id ) WHERE wtaxonomy.taxonomy = 'category' AND wtaxonomy.parent = 0 AND wtaxonomy.count > 0 AND wterms.term_id NOT IN (2,5,6)");
 
	$catCounter = 0;
 
	foreach ($catQuery as $category) {
 
		$catCounter++;
 
		$catStyle = '';
		if (is_int($catCounter / 2)) $catStyle = ' class="catAlt"';
 
		$catLink = get_category_link($category->term_id);
 
		echo '<li'.$catStyle.'><h3><a href="'.$catLink.'" title="'.$category->name.'">'.$category->name.'</a></h3>';
			echo '<ul>';
 
			query_posts('cat='.$category->term_id.'&showposts=5');?>
 
			<?php while (have_posts()) : the_post(); ?>
				<li><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
			<?php endwhile; ?>
 
				<li><a href="<?php echo $catLink; ?>" title="<?php echo $category->name; ?>">More <strong><?php echo $category->name; ?></strong></a></li>
			</ul>
		</li>
		<?php }	?>
	</ul>

随机日志

欢迎订阅: Google Reader | 鲜果 | 抓虾 | 九点 | QQ邮箱 | 有道 | 更多

4 条评论

  • (Required)
  • (Required, will not be published)