2012-11-29 71 views

回答

2
<?php 
    $category_id = get_cat_ID('Category Name'); 
    $q = 'cat=' . $category_id; 
    query_posts($q); 
    if (have_posts()) : while (have_posts()) : the_post(); 

    the_content(); 

    endwhile; endif; 
?> 

从WordPress的法典措施:http://codex.wordpress.org/Function_Reference/get_cat_ID

+1

非常感谢。我期待着向你们学习。 再次感谢,.... –

1

你试试?

global $wp_query; 
$cat_ID = get_query_var('cat'); 
+0

谢谢,您的快速回复。此代码是否为指定的类别名称查找类别ID? –

相关问题