我试图在帖子上显示帖子列表,包括他们的标题和图像。Im 使用带有数组的函数来过滤帖子。我知道获取帖子图像,但是当我在输出上使用它时,它会向我显示当前帖子的图像,而不是过滤后的图像(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 ?>
我想向每个(帖子)显示相应的图像。$evento
慕妹3242003