我無法正常工作。有人可以爲類別模板提供一個快速片段,顯示屬於名爲「產品A」的類別的帖子。在過去的3個小時裏,我一直使用試錯法,但沒有運氣。顯示屬於某個類別的帖子 - Wordpress
謝謝!
這是我一直在玩什麼周圍 -
<?php
/*
Template Name: yadayada
*/
?>
<?php get_header(); ?>
<?php get_sidebar(); ?>
<?php query_posts('cat=32&showposts=5'); ?>
<div class="post">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<div class="post-description">
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
</div>
</div>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
</div>
爲什麼不向我們展示一些無法使用的試錯法? – maiorano84
'showposts'已棄用。嘗試使用'posts_per_page = 5'代替,這是[query_posts()](http://codex.wordpress.org/Function_Reference/query_posts)函數的適當參數。你還應該在末尾使用'wp_reset_query()'。不過,你不提WP版。 –