1
我IAM創建與此代碼的標籤的部分,是檢索標記和排除一些標籤也是一個函數,檢索和顯示圖像的標籤在WordPress
$args = array('name__like' => $name_like, 'exclude' => array(75,177,42,74,197,36,40,140,162,108,86,47,4,29,22,215,87,151,104),'order' => 'ASC');
$tags = get_tags($args);
if (!empty($tags) && !is_wp_error($tags)) {
$count = count($tags);
$i=0;?>
<ul class="my_term-archive">
<?php
foreach ($tags as $tag) {
$i++;
$tag_link = get_tag_link($tag->term_id);
$tag_id = get_tag_ID($tag->name);
if(strtolower(substr($tag->name,0,1)) !=$name_like){
continue;
}
//i need a function here to retrieve images with the id of the tag
//attached
//////
$html .= "<li><a href='{$tag_link}' id='{$tag_id}' title='{$tag->name} Tag' class='{$tag->slug}'>";
$html .= "{$tag->name}</a></li>";
}
}
echo $html;
?>
</ul>
然後我把這個代碼在我的功能。在WordPress PHP文件,使產品相關圖片的圖片同治標籤盒,所以我現在可以標記圖片,
function wptp_add_tags_to_attachments() {
register_taxonomy_for_object_type('post_tag', 'attachment');
}
add_action('init' , 'wptp_add_tags_to_attachments');
所以我的問題是如何找到並顯示由ID標記的圖像? 抱歉,我的英語不好,不是我的母語。任何幫助是非常受歡迎的。謝謝
感謝指出我在正確的方向這個解決方案適用於我 – user3765369