我正在开发一个wordpress主题,并希望显示一个名为'Artikel'的特定类别的帖子。但是,我的代码不起作用。这是我的代码:如何通过catogory过滤帖子?
<?php
$custom_query = new WP_Query([
'cat' => 'Artikel',
]);
if ($custom_query->have_posts()) {
while ($custom_query->have_posts()) {
$custom_query->the_post(); ?>
/* do things */
<?php
}
wp_reset_postdata();
}
?>
有谁知道我错过了什么?
您正在从wordpress中获取数据默认的帖子类型和类别? –