【发布时间】:2014-04-28 16:25:13
【问题描述】:
下面的代码显示具有匹配“页面名称”和“类别 slug”的帖子。但我试图让它使用自定义分类法。如何将其合并到以下内容中? 我在我的函数文件中使用它:
function my_get_posts( $category_name )
{
// set the criteria
$args = array(
'numberposts' => -1,
'category_name' => $category_name,
'post_type' => 'custom_type'
);
// return the object array of the posts.
return get_posts( $args );
}
这在我的页面中
<?php
$posts_returned = my_get_posts($post->post_name);
foreach ($posts_returned as $post_returned) {
$postlink = get_post_permalink($post_returned->ID);
?>
HTML HERE
<?php } ?>
【问题讨论】:
标签: php wordpress custom-post-type