我要做的是获取每个帖子的特定类别的条款,然后在此帖子中显示它。
我编写的代码应该很简单:
function wodarchive_entry($post_id = null) {
$post = get_post( $post_id );
$termsArray = get_the_terms( $post->ID, "category" );
//Get the terms for this particular item
$termsString = ""; //initialize the string that will contain the terms
foreach ( $termsArray as $term ) { // for each term
$termsString .= $term->name.' ';
$category_id = $term->parent;//create a string that has all the slugs
if($category_id == '203'){
echo $termsString;
}
}
}
顺便说一句,这不起作用。好吧,差不多。这也给了我其他类别的值,可能是因为if语句一直播放到找到条件为止。
答案 0 :(得分:1)
如果只想在Principal userPrincipal = request.getUserPrincipal();
if (userPrincipal != null) {
httpMessageContext.getHandler().handle(new Callback[] {
new CallerPrincipalCallback(httpMessageContext.getClientSubject(), userPrincipal) }
);
return AuthenticationStatus.SUCCESS;
}
中获得匹配项,则应将赋值放在if循环内。
$termsString