我正在一个页面上工作,我希望从与该帖子标题具有相同类别名称的类别中显示帖子(自定义帖子类型)。
我还在学习,这就是为什么我希望你们能帮助我。 :)
我有什么:
在页面上〜/ sneakers /(来自CPT' shoes')我想展示类别'运动鞋的文章。
这就是我现在所拥有的:
usage
nw [udp] <options> <host> <port>
Default TCP protocol can be changed to UDP by ``udp'' argument.
UDP options
currently none
TCP options
-f firewall mode, connection is initiated by netread.
Host specification is ignored and can be omited.
-c ignored. Transmission checksum is activated by
default.
-C algorithm use the specified algorithm for checksum. This
option also implies -c.
Supported algorithms (the first is default):
md5 none
general options
-i <file> read data from file instead of stdin.
-b print speed in b/s instead of B/s
-h <n> print `#' after each n KiB transferred (def. 10485.76).
-H <n> print `#' after each n MiB transferred (def. 10.24).
-q be quiet.
-v be verbose.
-vv be very verbose.
-V show version.
-vV show verbose version.
return values
0 no errors.
1 some error occured.
2 checksum validation failed.
答案 0 :(得分:0)
好的,根据问题和以下解释:
我们在显示单鞋信息的single-shoes.php
。
我们希望获取并显示有关articles
自定义帖子类型的信息,此文章必须属于特定类别,其名称为= post_title。
如果是这种情况,您可以执行以下操作:
articles
自定义帖子类型,因此必须将'post_type' => 'articles'
放在$args
数组中。'category_name' => get_the_title()
放入$args
代码是:
$args = array(
'orderby' => 'date',
'order' => 'DESC',
'post_type' => 'articles',
'posts_per_page' => -1,
'category_name' => get_the_title()
);
$articles = new WP_Query($args);
if ( $articles->have_posts() ) :
while( $articles->have_posts() ) : $articles->the_post(); ?>
<li><a href="<?php the_permalink();?>"><?php the_title();?></a></li>
<?php
endwhile;
endif;
wp_reset_postdata();
?>
P.S。我仍然对类别名称感到困惑,我仍然不确定我是否正确理解了这个值的来源,但是,如果你能抓住这个值,那么查询就是这个。