検索した賞賛(get_terms
を使用)をカテゴリ名で限定しようとしています。 category_name = "xxx"は何もしていないようですので、私は迷っています。カテゴリ名でwp_termsを取得
function testimonial_shortcode($atts) {
$cat = $atts['cat'];
$testim='<div id="owl-demo" class="owl-carousel owl-theme">';
$terms = get_terms(array(
'taxonomy' => 'testimonial',
'category_name' => $cat,
'hide_empty' => true,
));
foreach($terms as $custom_texonomy){
$imageid=get_option("testimonial_".$custom_texonomy->term_id."_testimonials__image");
$imgurl=wp_get_attachment_image_src($imageid, 'full');
$testim.=' <div class="item">
...
}
add_shortcode('testimonialcat', 'testimonial_shortcode');
この種の作品。基本的に、私が今見ているのは、そのカテゴリの最初の投稿です。そして、ループは止まります。それがどんなアイデアなのか? – Lukerb
名前を1つだけ検索すると、1つの結果しか期待できません。 'get_terms'はあなたが検索した用語の詳細を返します。あなたはあなたの分類法にその名前の用語が1つしかないと仮定します。その言葉に関連する投稿を取得しようとしていましたか? – FluffyKitten
ええと...カスタム投稿タイプのカテゴリからすべてのものをループしようとしています...どんな提案ですか? – Lukerb