我試圖在帖子上顯示帖子列表,包括他們的標(biāo)題和圖像。Im 使用帶有數(shù)組的函數(shù)來(lái)過(guò)濾帖子。我知道獲取帖子圖像,但是當(dāng)我在輸出上使用它時(shí),它會(huì)向我顯示當(dāng)前帖子的圖像,而不是過(guò)濾后的圖像(get_posts()$template_loader->get_template_part( 'content-listing-image');$evento)這是我的代碼:<?php $args = array( 'author' => $post->post_author, 'order' => 'ASC', 'posts_per_page' => -1, 'meta_query' => array( array( 'key' => '_listing_type', 'value' => 'event' ) )); $eventos = get_posts( $args ); foreach ( $eventos as $evento ) { $template_loader = new Listeo_Core_Template_Loader; $output .= '<div><a href="'.get_permalink( $evento->ID ).'" target="_blank"> '.$template_loader->get_template_part( 'content-listing-image').' '.$evento->post_title.'</a></div>'; } if(!empty($eventos)) : ?> <div id="listing-eventosartista" class="listing-section"> <h3 class="listing-desc-headline margin-top-60 margin-bottom-30"><?php esc_html_e('Eventos','listeo_core'); ?></h3> <div class="single-item"> <?php echo $output; ?> </div> </div> <?php endif ?>我想向每個(gè)(帖子)顯示相應(yīng)的圖像。$evento
1 回答
慕妹3242003
TA貢獻(xiàn)1824條經(jīng)驗(yàn) 獲得超6個(gè)贊
您可以使用get_the_post_thumbnail(),如下所示
$output .= 'ID ).'" target="_blank"> '.get_the_post_thumbnail( $evento->ID).' '.$evento->post_title.'';
- 1 回答
- 0 關(guān)注
- 129 瀏覽
添加回答
舉報(bào)
0/150
提交
取消
