Php Wordpress&x2B;分类发帖
我是wordpress的新手,所以这可能是一个非常明显的问题 我如何才能只获得特定类别的帖子。试试这个:Php Wordpress&x2B;分类发帖,php,wordpress,Php,Wordpress,我是wordpress的新手,所以这可能是一个非常明显的问题 我如何才能只获得特定类别的帖子。试试这个: <?php $posts = get_posts(array('category' => 1)); ?> 试试这个: <?php $posts = get_posts(array('category' => 1)); ?> 您也可以尝试以下其他方法 <?php $post = query_posts( array (
<?php
$posts = get_posts(array('category' => 1));
?>
试试这个:
<?php
$posts = get_posts(array('category' => 1));
?>
您也可以尝试以下其他方法
<?php
$post = query_posts( array ( 'category_name' => 'uncategorized') );
$post = query_posts( array ( 'category_slug' => 'uncategorized') );
$post = query_posts( array ( 'category' => 1) );
?>
您也可以尝试以下其他方法
<?php
$post = query_posts( array ( 'category_name' => 'uncategorized') );
$post = query_posts( array ( 'category_slug' => 'uncategorized') );
$post = query_posts( array ( 'category' => 1) );
?>
我鼓励您使用WP\u查询:
<?php
// The Query
$the_query = new WP_Query(
'category_name' => 'slug-of-category',
);
// The Loop
while ( $the_query->have_posts() ) :
$the_query->the_post();
echo '<li>' . get_the_title() . '</li>';
endwhile;
// Restore original Query & Post Data
wp_reset_query();
wp_reset_postdata();
?>
我鼓励您使用WP\u查询:
<?php
// The Query
$the_query = new WP_Query(
'category_name' => 'slug-of-category',
);
// The Loop
while ( $the_query->have_posts() ) :
$the_query->the_post();
echo '<li>' . get_the_title() . '</li>';
endwhile;
// Restore original Query & Post Data
wp_reset_query();
wp_reset_postdata();
?>
_title();
_摘录();
_permalink();
_内容();
endforeach;
wp_reset_postdata();
?>
_title();
_摘录();
_permalink();
_内容();
endforeach;
wp_reset_postdata();
?>
你为什么鼓励它?你为什么鼓励它?