【发布时间】:2016-08-04 19:55:19
【问题描述】:
我已将此代码用于滑块以显示选择用户选择类别的帖子,但在添加此代码后,即使我尝试过,它也不会在自定义字段或任何其他 php 代码之后选择..
这是我应用的代码
<div class="blog-posts-slider">
<?php $temp_query = $wp_query;
$category_name = get_field('business_solutions_category_name');
query_posts(array(
'category_name' => $category_name,
'posts_per_page' => 5
)
);
while (have_posts()) : the_post();
$thumb_id = get_post_thumbnail_id();
$thumb_url_array = wp_get_attachment_image_src($thumb_id, 'thumbnail-size', true);
$thumb_url = $thumb_url_array[0];
?>
<div class="slider-single-post">
<div class="blog-image" style="background-image : url('<?php the_post_thumbnail_url(); ?>');"></div>
<div class="slider-post-text">
<h3><?php the_title(); ?></h3>
<p><?php the_excerpt(); ?></p>
<a href="<?php the_permalink(); ?>">Read More</a>
</div>
</div>
<?php endwhile;
$wp_query = $temp_query; ?>
</div>
我对 php 不太熟悉.. 但我认为它在 endwhile 或该行下方是错误的.. 我错过了一些东西.. 提前致谢。
【问题讨论】: