Php 按指定类别筛选和显示自定义文章类型的文章?
我有一个自定义的帖子类型叫做“服务”,它的slug叫做“服务”。如图所示,它们都有自己指定的类别Php 按指定类别筛选和显示自定义文章类型的文章?,php,html,wordpress,filter,custom-post-type,Php,Html,Wordpress,Filter,Custom Post Type,我有一个自定义的帖子类型叫做“服务”,它的slug叫做“服务”。如图所示,它们都有自己指定的类别 我如何编写一个WP_查询/循环来显示所有“服务”的标题以及类别“Face”?还带有指向各自页面的超链接。下面是实现所需结果的代码 $args = array( 'post_type' => 'services', 'category' => 'Face', ); $loop = new WP_Query( $args ); if ( $loop->have_p
我如何编写一个WP_查询/循环来显示所有“服务”的标题以及类别“Face”?还带有指向各自页面的超链接。下面是实现所需结果的代码
$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; ?>
令人惊奇,工作起来很有魅力&超级简单。谢谢你所做的一切您好@raju_eww如果我想将此代码复制七次,但每一次都有不同的类别,您知道我应该如何使用此代码吗?我已经回答了您最近提出的问题,请查看并标记为有用,如果有用,那么它将对其他人有帮助