調用wordpress指定分類文章第一種方法:
- <?php $posts = get_posts( "category=4&numberposts=10" ); ?>
- <?php if( $posts ) : ?>
- <ul><?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
- <li>
- <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>
- </li>
- <?php endforeach; ?>
- </ul>
- <?php endif; ?>
調用wordpress指定分類文章第二種方法:
- <h2><?php wp_list_categories('include=11&title_li=&style=none'); ?></h2> //輸出 ID 為11的分類的標題
- <?php echo category_description(11); ?> //輸出 ID 為11的分類的描述
- <?php query_posts('showposts=5&cat=11'); ?> //query_posts 給 The Loop 限定的條件是:顯示5篇日志和分類 ID 為11
- <?php while (have_posts()) : the_post(); ?> //The Loop 開始
- <li><a href="<?php the_permalink() ?>" rel="bookmark" class="title"><?php the_title(); ?></a></li> //用列表的方式輸出帶有鏈接的文章標題
- <?php endwhile; ?> //The Loop 結束
新聞熱點
疑難解答
圖片精選