2011年10月6日木曜日

(Wordpress)今表示しているページのカテゴリID取得の仕方

 
例)
 
<?php if ( have_posts() ) : 
foreach((get_the_category()) as $cat) {
$cat_id = $cat->cat_ID ;
break ; 
}
$query = 'cat=' . $cat_id. '&showposts=3';
query_posts($query) ; 
?>
<ul>
 <?php while (have_posts()) : the_post(); ?>
 <li>
   <?php the_content();?>
 </li>
 <?php endwhile;?>
 </ul>
<?php endif; ?>
 
 
参考サイト
http://blog.magical-remix.net/igalog/archives/96 
http://blog.magical-remix.net/igalog/archives/99 

0 件のコメント: