【发布时间】:2020-08-08 21:42:37
【问题描述】:
我的代码:
if (!empty($packs = get_post_meta(get_the_ID(), 'pack', true))):
if ( false === ( $q = get_transient( 'packs_list' ) ) ) {
$params = array(
'post_type' => 'product',
'posts_per_page' => '7',
'meta_query' => array(
array(
'key' => 'package_pack',
'value' => $packs,
'compare' => 'IN'
)
)
);
$wp_query = new WP_Query($params);
echo '<div class="products list_">';
while ($wp_query->have_posts()) : $wp_query->the_post();
$q = include(rh_locate_template('inc/parts/main.php'));
endwhile;
echo '</div>';
set_transient( 'packs_list', $q, 1 * HOUR_IN_SECONDS );
wp_reset_postdata();
}
endif;
我正在尝试将整个生成的帖子列表保存为瞬态的 html,但不起作用。如何将此循环的 html 输出保存到瞬态?
【问题讨论】: