Web前端总结(第五篇)实现文章刷新自动变化随机调用
闪灵科技(开发者团队)介绍:Web前端总结(第五篇)开发者如何实现文章刷新自动变化随机调用实战讲解:
//调用缩略图
<?php
//$caseIDS= get_field(‘home_cases’);
$caseIDS= 5;
$args = array(
‘post_type’ => ‘product’,
‘posts_per_page’ => 8,
‘post_status’ => array(‘publish’),
‘orderby’ => ‘rand’,//按随机调用,如果不要随机可以把这行删除
‘orderby’ => ‘date’,
‘order’ => ‘DESC’,
‘tax_query’ => array(
array(
‘taxonomy’ => ‘products’,
‘field’ => ‘id’,
‘terms’ => $caseIDS,
)
),
);
query_posts($args);
while (have_posts()) : the_post(); ?>
在开发工作中使用该函数调用法可实现文章刷新自动变化随机调用,使用下面的调用代码块中,来调用缩略图:
<?php if ( has_post_thumbnail() ) { the_post_thumbnail(array(296,296),array(‘alt’=> trim(strip_tags( $post->post_title ))));} else {?><img src=”<?php echo get_first_image(); ?>” alt=”<?php the_title(); ?>” width=”296″ height=”296″/><?php }?>