我有一个正确加载的get\\u术语
在它里面,我用过get\\u帖子。然后使用get posts,我正在尝试获取每个post标记(count<;=当前不在此脚本中)
<?php
$categories = get_terms( \'blogs_cat\', array(
\'type\' => \'blogs\',
\'orderby\' => \'name\',
\'order\' => \'ASC\',
\'hide_empty\' => 0,
\'exclude\' => \'1\',
\'number\' => \'1000\',
\'pad_counts\' => true
)
);
echo \'<div class="clientList">\';
echo \'<ul>\';
foreach ($categories as $category) {
$colorClass = \'\';
// COUNT NUMBER OF TAGS AKA: PUBLISHED / NOT PUBLISHED ARTICLES
$termID = $category->term_id;
$taxonomyNAME = $category->taxonomy;
$termSLUG = $category->slug;
$items = get_posts( array(
\'post_type\' => \'blogs\',
\'numberposts\' => -1,
\'taxonomy\' => $taxonomyNAME,
\'term\' => $termSLUG
) );
$totalPostsCount = count( $items );
// WHEN PRINT_R EACH ITEM RETURNS UNIQE ID
foreach ($items as $item) {
$posttags = get_the_tags($item->term_id);
if ($posttags) {
foreach($posttags as $tag) {
// HERE I GET SAME TAG NAME FOR ALL TAGS ACROSS POSTS (IN THIS CASE ITEMS)
echo $tag->name;
}
}
}
//print_r($category);
echo \'<li class="\'.$listClass.\'"><div class="clientContainer"><a href="\' . get_term_link($category->slug, \'blogs_cat\') . \'" title="\' . sprintf( __( "All Articles By: %s" ), $category->name ) . \'" \' . \'>\' . $category->name.\'</a><div class="articleCount \'.$colorClass.\'"> (\'.$totalPostsCount.\' / p\'.$publishedArticle.\') </div></div></li>\';
}
echo \'</ul>\';
echo \'</div>\';
?>
。
问题是“echo$tag->name;”返回始终相同的标记。。有谁能帮我发现问题/提供更好的方法吗?我可能会和这个脚本混在一起。
谢谢
EDIT 1 - RESPONSE TO: @tollmanz
当我*“print\\u r($项目);”*在foreach中,我得到了这样一个信息(与存在的每个帖子都有自己的细节):
stdClass Object (
[ID] => 875
[post_author] => 1
[post_date] => 2012-06-25 14:34:53
[post_date_gmt] => 2012-06-25 11:34:53
[post_content] => Content Content Content
[post_title] => itle Example
[post_excerpt] =>
[post_status] => publish
[comment_status] => open
[ping_status] => open
[post_password] =>
[post_name] => post-name
[menu_order] => 0
[post_type] => blogs
[post_mime_type] =>
[comment_count] => 0
[filter] => raw
)
。
而且当我回显$项目->ID我得到了正确的帖子id。
但当我尝试*“打印($posttags);”*
此行后:“$posttags=get\\u标签($item->ID);”*
i get nothing... any ideas why?