飞龙博客

feilong.org 前端开发教程

get tags in category get terms of related taxonomies

飞龙修订于 20110217 04:08 49 次浏览
query($args);
while ($flposts->have_posts()) : $flposts->the_post();
$postterms = get_the_terms($post->ID,$taxonomy);
if ($postterms) {
foreach($postterms as $term) {
$all_termids[] = $term->term_id;
}
}
endwhile;
if($all_termids){
$termids = array_unique($all_termids); //REMOVES DUPLICATES of an array of one dimension 
return $termids;
}
}

/** 2. get posts by  certion termslug of certain taxonomy or post type **/
$taxonomy='singer';
$termslug='zhangye';
$args=array(
'post_type'=>'post',
'orderby'=>'count',
'posts_per_page'=>-1,
$taxonomy=> $termslug //certain termslug of this taxonomy 'singer'
);
$relatedtaxonomy='post_tag';
$termids=feilong_get_termids($args,$relatedtaxonomy);


/** 3. functions.php feilong.org, if you know termids, 
then function to list these terms in thumbnails links or dls format **/
function feilong_list_terms_by_ids($termids,$taxonomy,$thumbornot='0',$linkbefore='',$linkafter='',$gap=''){
foreach ($termids as $termid) {
$term=get_term( $termid, $taxonomy );
$termlink = get_term_link( $term, $taxonomy );
$termname=$term->name;
$termimg=''.$termname.'';
$termposts=$term->count;
if ( !is_wp_error( $termlink ) )
echo $linkbefore;
if ($thumbornot=='1') {
echo ''.$gap;
} elseif($thumbornot=='0') {
echo ''.$gap;
}else{
echo '
'.$termimg.'
'; echo '
'.$termname.'
'; echo '
'.$termposts.' 个视频
'; } echo $linkafter; } } /** 4. if termids,then list them in links **/ if($termids){ feilong_list_terms_by_ids($termids,$relatedtaxonomy,$thumbornot='0',$linkbefore='',$linkafter='',$gap=', '); } //feilong.org tags in category,or terms of related taxonomy ?>

网址:https://feilong.org/tags-in-category-terms-of-related-taxonomy
初发:20110217 04:08

想学前端?长按二维码加我微信

想学前端?点击飞龙QQ

分类: wordpress

新作:

旧文:

关闭

长按二维码 -> 识别图中二维码

打开微信,发现,扫一扫

支付完成后,点击下一步

感谢大力支持

然后你手机号:

最后点这,稍等即可