我有一个自定义帖子类型,称为“服务”,它的子句称为“服务”。如该图所示,它们都有自己分配的类别。
如何编写一个WP_Query / loop来显示类别为“ Face”的所有“服务”的标题? (还具有指向各自页面的超链接。)
答案 0 :(得分:1)
下面是将实现所需结果的代码
$args = array(
'post_type' => 'services',
'category' => 'Face',
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) :
while ( $loop->have_posts() ) : $loop->the_post(); ?>
----Here will be your html in which format you want to display your title-----
<p><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p>
<?php endwhile;
endif; ?>