下面的代码将从特定类别名称中获取文章标题。
<?php
$myposts = get_posts(array(
\'showposts\' => 8, //add -1 if you want to show all posts
\'post_type\' => \'your-post-type\',
\'tax_query\' => array(
array(
\'taxonomy\' => \'your-taxonomy\',
\'field\' => \'slug\',
\'terms\' => \'term-name\' //pass your term name here
)
))
);
foreach ($myposts as $mypost) {
// echo $mypost->post_title . \'<br/>\';
// echo $mypost->post_content . \'<br/>\';
// echo $mypost->ID . \'<br/><br/>\';
echo \'<li class="faq"> <p class="title"><a href="\' . get_permalink($mypost) . \'">\' . $mypost->post_title . \'</a></p></li>\';} ?>